From 13fbf00315f65054d3340fdff470cde43b051782 Mon Sep 17 00:00:00 2001 From: bong-water-water-bong Date: Sat, 14 Nov 2026 03:15:24 -0400 Subject: [PATCH 1/2] pr_review_queue: a non-list page is an error, not a list of strings The queue crashed outright at 07:13Z: body = r.get('body') or '' AttributeError: 'str' object has no attribute 'get' `gh()` paginated does `out.extend(json.loads(chunk))`. A list endpoint answers with a list, but an error object (`{"message":"API rate limit exceeded"}`, a 404, a renamed repo) is a **dict**, and `extend(dict)` extends with the dict's **keys** - strings - which then explode in `reviewed_at`. So one transient API error took out the whole queue. Now a non-list page raises, naming the endpoint and the message, and `main` returns 2: pr_review_queue: gh api repos/OWNER/REPO/pulls?state=open did not answer with a list: Not Found rc=2 Reported rather than skipped, because a failed read must not come out as "every open PR has a verdict" - that is the same false negative this tool exists to prevent (a verdict that exists read as absent). Arm drives the real `gh` path through a stub that answers an error object; disabling the guard fails it (1 FAIL). Verified end to end against a repository that does not exist: rc 2 with the message above. --- tools/ci/pr_review_queue.py | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/tools/ci/pr_review_queue.py b/tools/ci/pr_review_queue.py index 2ae59e08e..86eae09db 100755 --- a/tools/ci/pr_review_queue.py +++ b/tools/ci/pr_review_queue.py @@ -58,6 +58,14 @@ def gh(path, paginate=False): got = json.loads(chunk or '[]') except json.JSONDecodeError: break + # A list endpoint answers with a list. An error object (`{"message": ...}`, a rate limit, a renamed repo) is a + # dict, and `out.extend(dict)` silently extends with the DICT'S KEYS - strings - which then explode in the + # caller as `'str' object has no attribute 'get'` (this crashed the whole queue on 2026-11-14 07:13Z). Reported, + # not skipped: a failed read must not come out as "no verdicts exist", which is exactly the false-negative this + # tool exists to avoid. + if not isinstance(got, list): + msg = got.get('message', got) if isinstance(got, dict) else got + raise RuntimeError(f"gh api {path} did not answer with a list: {msg}") if not got: break out.extend(got) @@ -189,6 +197,24 @@ def chk(want, got, what): 'a verdict naming a longer sha of the same head counts too') chk(False, reviewed_at([{'body': 'VERDICT: READY at `9999999`'}], 'abc1234'), 'a verdict at a DIFFERENT head does not count: that is the case the queue exists for') + # The 07:13Z crash, reproduced from the shape that caused it: an error object where a list belongs. A guard that + # cannot fail is not a guard, so this drives `gh` itself (a stubbed binary) rather than a hand-built list. + import tempfile as _tf, os as _os + _d = _tf.mkdtemp() + _stub = _os.path.join(_d, 'gh') + with open(_stub, 'w') as f: + f.write('#!/bin/sh\nprintf \'{"message":"API rate limit exceeded"}\'\n') + _os.chmod(_stub, 0o700) + _old = _os.environ.get('PATH', '') + _os.environ['PATH'] = _d + ':' + _old + try: + gh('repos/x/y/pulls?state=open', paginate=True) + crashed = 'no exception' + except RuntimeError as e: + crashed = 'rate limit' in str(e) + finally: + _os.environ['PATH'] = _old + chk(True, crashed, 'a non-list page is reported, not extended into the queue as strings') chk(False, reviewed_at([{'body': 'looks good to me'}], 'abc1234'), 'a review without a verdict line does not count') # The guard is the VERDICT word, not the head: removing it left --self-test at rc 0, because every arm above @@ -285,7 +311,11 @@ def main(argv): held = [row for row in rows if row['kind'] == 'CHANGES'] print(f"pr_review_queue --state: {len(rows)} open PR(s), {len(held)} whose newest verdict is CHANGES") return 0 - q = queue(a.repos, a.min_age_hours) + try: + q = queue(a.repos, a.min_age_hours) + except RuntimeError as e: + print(f"pr_review_queue: {e}", file=sys.stderr) + return 2 if a.json: print(json.dumps(q, indent=1)) return 0 From ac12b974594a15922b627bee0a5fb637a4df8ccb Mon Sep 17 00:00:00 2001 From: bong-water-water-bong Date: Sat, 14 Nov 2026 04:07:52 -0400 Subject: [PATCH 2/2] pr_review_queue: a QUOTED verdict is not a verdict Found while reading my own PRs with `--state` (which #2400 added): it reported npu-kernels#70 as held by a CHANGES at 14:51Z. That "verdict" was **my own reconciliation comment**, which quotes the verdict it disagrees with: `VERDICT: NEEDS-CHANGE` at `8a27d70c5` measured: `VERDICT_LINE` allows markdown decoration before VERDICT (bold, list bullets), and a backtick is decoration too - so a quotation of someone else's verdict at the head read as a verdict by the author. The same applies to a comment that quotes the *format* (`Write it as \`VERDICT: READY at \``). A verdict does not begin inside an inline code span: VERDICT_LINE ^(?![^A-Za-z0-9]*`[^`]*VERDICT)[^A-Za-z0-9]*VERDICT\b VERDICT_KIND same exclusion -- `--state` classifies through it Measured on the real comment: `verdict_kind` -> None, `reviewed_at` -> False; and it is not a one-way narrowing - the house forms still read (bold `**VERDICT: READY at \`abc1234\`**`, bare, list-decorated). After the fix `--state --repos npu-kernels` reports #70 as `newest=READY 2026-11-13T06:40:19Z`, the reviewer's actual verdict. Two arms added (quoted verdict, quoted format); removing the exclusion fails **4** arms. --- tools/ci/pr_review_queue.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/tools/ci/pr_review_queue.py b/tools/ci/pr_review_queue.py index 86eae09db..c49b70143 100755 --- a/tools/ci/pr_review_queue.py +++ b/tools/ci/pr_review_queue.py @@ -75,10 +75,14 @@ def gh(path, paginate=False): return json.dumps(out) -VERDICT_LINE = re.compile(r'^[^A-Za-z0-9]*VERDICT\b', re.MULTILINE) +# A verdict does not begin inside an inline code span. Lanes quote the verdict *format* (`` `VERDICT: READY at +# `abc1234` ``) and quote **other people's** verdicts when reconciling them, and both were being read as verdicts by the +# author. Measured 2026-11-14: this lane's own reconciliation comment on npu-kernels#70 quoted `VERDICT: NEEDS-CHANGE` at +# the head, so `--state` reported a READY PR as held by a CHANGES that no reviewer had written. +VERDICT_LINE = re.compile(r'^(?![^A-Za-z0-9]*`[^`]*VERDICT)[^A-Za-z0-9]*VERDICT\b', re.MULTILINE) -VERDICT_KIND = re.compile(r'^[^A-Za-z0-9]*VERDICT\b[^\n]*', re.MULTILINE) +VERDICT_KIND = re.compile(r'^(?![^A-Za-z0-9]*`[^`]*VERDICT)[^A-Za-z0-9]*VERDICT\b[^\n]*', re.MULTILINE) def verdict_kind(body): @@ -215,6 +219,12 @@ def chk(want, got, what): finally: _os.environ['PATH'] = _old chk(True, crashed, 'a non-list page is reported, not extended into the queue as strings') + # The false POSITIVE, measured on my own comment (npu-kernels#70, 07:5xZ): reconciling two verdicts quotes the one being + # disagreed with, and the quote named the head. A quotation is not a verdict - in either direction. + chk(False, reviewed_at([{'body': '`VERDICT: NEEDS-CHANGE` at `abc1234` measured:'}], 'abc1234'), + 'a backticked verdict being QUOTED is not a verdict at this head') + chk(False, reviewed_at([{'body': 'Write it as `VERDICT: READY at `'}], 'abc1234'), + 'quoting the verdict FORMAT is not a verdict either') chk(False, reviewed_at([{'body': 'looks good to me'}], 'abc1234'), 'a review without a verdict line does not count') # The guard is the VERDICT word, not the head: removing it left --self-test at rc 0, because every arm above