Repository navigation
fix(audit-merges): retry the /pulls read instead of dying on an empty reply - #3128
Conversation
One empty `gh api` reply (`JSON.parse('')` -> unexpected end of JSON input) ended the patrol with
exit 1 and no finding, so "the API hiccuped" and "a merge skipped the queue" were the same red. The
read is now retried 3 times with a short backoff; when it still fails the run fails with
`could not read the pulls of <sha> after 3 attempts: <reason>` and never reports that commit as
bypassed or direct. A `[]` from /pulls stays an answer.
Docs-not-needed: .github/scripts/audit-merges.mjs is a read-only patrol script; no subsystem page
owns it and this change adds no interface.
|
Verdict: PASS at bc19cac Ran at this tip: Red first: a fresh copy at this tip with only Restoring the tip blob (git blob b920da2caa1173a541e99343369346bd57147742, the same blob the API reports for this path) takes it back to 22/22. Review points:
Body note: I corrected the description's |
|
Verdict: PASS at bc19cac Reviewed at this tip 2026-11-17T00:49Z (UTC), tarball of bc19cac. T2 report-only check at the head; no hold on the pull request. Ran at this tip: Review points:
Enqueue next: the head is unchanged and the guard's remaining reasons are fixed in the body. |
Written-by: Dev
Fixes #3127
Owner: Dev
Reviewer: Reviewer
Tip SHA: bc19cac
Base: fc198e3
Docs-not-needed: .github/scripts/audit-merges.mjs is a read-only patrol script; no
docs/subsystems/page lists it inowned_paths, and this change adds no subsystem interface.What changed
Before: one empty
gh apireply madeJSON.parse('')throwunexpected end of JSON inputin the only read of/commits/<sha>/pulls,main()rethrew it, and the patrol exited 1 with no finding —audit-merges: N commits on main, X bypassed the queue, Y directnever printed. "The API hiccuped" and "a merge skipped the queue" were the same red, and the unaudited window3773d257..cf00e675stayed unaudited.After:
retryRead— 3 attempts, 100 ms then 200 ms backoff — so an empty stdout, a nonzeroghexit and a non-JSON body are retried instead of ending the run (.github/scripts/audit-merges.mjs:138-166);/pullsread still fails,main()throwscould not read the pulls of <sha> after 3 attempts: <reason>— the commit is named, and it is thrown, never pushed as a finding, so it can print neitherbypassed queue:nordirect commit:(:190-196);[]from/pullsis still an answer:?? []is kept insidepullsFor(:192);exitCodeFor,classify,audit/auditCommitand the watermark are untouched.Not a gate file, contrary to the brief:
policy/gates.jsonlists nine.github/scripts/*.mjsfiles andaudit-merges.mjsis not among them, so this PR needs nopolicy-sign. NoPolicy-sign:line is written here.Verification at the tip
Tip SHA: bc19cac
Ran:
node --test .github/scripts/audit-merges.test.mjs→ 22 tests, 22 pass, 0 fail.Ran: same command before the fix, same tree → 22 tests, 20 pass / 2 fail —
not ok 19(retry then answer) andnot ok 20(never answers, names the commit). The 18 tests that existed before were green both before and after; the bypass fixture still exits 1 (result.bypassed: 1,exitCodeFor(...) === 1).Ran:
node --test ".github/scripts/*.test.mjs"→ 675 tests, 673 pass, 0 fail, 2 skipped.Ran: the real reader path, not a fixture —
main({ gh })whereghprints the commit list and then an empty string for/pulls:Not run:
TZ=UTC npm run verifyin this session — this box has no git binary, and the first step (arch-docs) diffs againstorigin/main, so it aborts witharch-docs: FAIL — cannot diff against origin/mainbefore reaching the tests. CI at this tip runs the same command:tests-okis green on this tip (thetestjob, pluspackage,policy-sign, both plugin matrices), which is the authoritativenpm run verify.policy-signis green becauseaudit-merges.mjsis not inpolicy/gates.json— no signature is needed and none is written.Checkpoint
{ "pr": 3128, "claim": "Dev", "issue": 3127, "summary": "One transient empty gh api reply turned the merge patrol red with no finding, because the single /pulls read parsed '' and main() rethrew it. Reads are now retried three times with a short backoff, and a read that still fails throws 'could not read the pulls of <sha> after 3 attempts: <reason>' naming the commit instead of reporting it as bypassed or direct. An empty /pulls list stays a valid answer, and finding/watermark semantics are unchanged. Tests cover retry-then-answer, never-answers, the bypass fixture still exiting 1, and [] not being retried.", "files": [".github/scripts/audit-merges.mjs", ".github/scripts/audit-merges.test.mjs"], "checks": { "ran": "node --test .github/scripts/audit-merges.test.mjs (22/22) and node --test \".github/scripts/*.test.mjs\" (675 tests, 673 pass, 0 fail); CI tests-ok green at the tip", "result": "green", "at": "bc19cac8e435e6186989724cd476894f2396b0f5" }, "next": "Reviewer: judge the tip; the retry, the named error and the unchanged bypass exit are the three things to check." }