Skip to content

fix(pr-pipeline): leave post-merge-dispatch slack and resend only unsent dispatches - #9354

Merged
kyle-sexton merged 1 commit into
mainfrom
fix/pr-merge-dispatch-slack
Oct 23, 2026
Merged

kyle-sexton merged 1 commit into
mainfrom
fix/pr-merge-dispatch-slack

Conversation

@kyle-sexton

Copy link
Copy Markdown
Member

Refs: #9297

Summary

A follow-up to #9346, which added a rate-limit retry to pr-merge's full-run dispatch after the GITHUB_TOKEN exhaustion at 05:26Z on 2026-10-23. That exhaustion failed the dispatch on runs 39905758340, 39905868587 and 39906176584. Review of #9346 found two gaps:

  • post-merge-dispatch (timeout-minutes: 15) allowed up to 300 s of dispatch waits ahead of the re-run step, which sleeps up to 170 s reading back attempt 2. That left little slack. A timeout after the re-run POST leaves attempt 2 without its pr-merge-rerun-<id>-attempt-2 record.
  • The no-response branch resent the dispatch even when the first request may already have created a run. A second run has no pr-merge-dispatched-<id> record and trips the post-merge check's unlisted-record hold.

Fix

  • (a) The cap was lowered, not the timeout raised. post-merge-dispatch caps its dispatch waits at 180 s (was 300 s), and its timeout stays at 15 minutes. Measured on the last ten scheduled pr-merge runs: the whole job took 97-127 s, of which the post-merge check took 81-111 s, and the dispatch and re-run steps did not run. Adding 180 s of waits, the re-run step's 170 s of read-back sleeps and about 20 s of reads and uploads gives about 8.5 minutes, which leaves about 6.5 for slow reads. A longer timeout would hold the job longer and protect against nothing the lower cap leaves open. With 180 s, a secondary limit's 60 s wait still fits twice. The arithmetic is in the yaml comment.
  • (b) No response is resent only when the request never left. gh's stderr is kept for each attempt, and still printed to the log. A no-response failure is resent, after the same full-jitter backoff, only when that stderr shows a dial tcp error (DNS lookup, refused or unreachable connection, connect timeout) or a failed TLS handshake. A reset or timeout on an open connection, or no error text at all, warns and stops as on exhaustion: no run id, no record, and the next push or scheduled run starts the run. This applies to both jobs, whose dispatch bodies stay identical (a test checks this).

Verification

  • node --test in .github/scripts/pr-merge: exit 0, 182 tests. Expected values come from the rules above:
    • a DNS failure and a refused connection are resent and the run starts on the third POST;
    • a TLS handshake failure is resent once;
    • read: connection reset by peer, Client.Timeout exceeded while awaiting headers and an empty error each make exactly one POST, no sleep, and a warning;
    • in post-merge-dispatch, a Retry-After: 181 is not taken, while two 60 s waits are.
  • Mutants: always resending, never resending, and restoring the 300 s cap each turned the suite red; restored, green.
  • actionlint .github/workflows/pr-merge.yml: exit 0. bash scripts/check-affected.sh --tests: exit 0 (10 passed, 4 skipped). babysit-prs python3 -m unittest discover -s tests -t .: exit 0, 2,537 tests. bash scripts/run-ruff.sh check plugins/source-control/skills/babysit-prs: exit 0.
  • Left out: a live network failure. No workflow was dispatched or re-run.

Related

🤖 Generated with Claude Code

…ent dispatches

post-merge-dispatch caps its dispatch waits at 180 s instead of 300 s.
The job measured 97-127 s on recent scheduled runs, and the re-run step's
read-back sleeps up to 170 s, so the lower cap keeps a timeout from
landing after the re-run POST. Both dispatch steps resend after no
response only when gh's error shows the connection failed before the
request was sent (dial tcp or a TLS handshake); otherwise they warn and
stop, since the run may exist.

Refs: #9297

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kyle-sexton
kyle-sexton marked this pull request as ready for review October 23, 2026 06:47
@kyle-sexton
kyle-sexton marked this pull request as draft October 23, 2026 06:47
@kyle-sexton
kyle-sexton marked this pull request as ready for review October 23, 2026 06:47
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-23T06:51:46.023505Z — Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions

github-actions Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

claude-review reviewed 053361defd03287b9abb5010f446b1a2e6693833: 0 finding(s), 0 as inline comments.

No findings. I read all three changed files in full (pr-merge.yml dispatch step, workflow.test.mjs, the changelog fragment) and checked the diff against the PR description. I had no shell, so I ran nothing. The test counts and mutant results in the PR body are author-claimed and unverified by me.

What I checked:

  • Resend rule (both jobs). The two dispatch bodies match. 2>"$RUNNER_TEMP/dispatch-stderr" is overwritten on each attempt and echoed back to the log. A resend happens only when stderr matches dial tcp or tls: (handshake|first record). A reset, a timeout on an open connection, or empty stderr falls through with wait empty, so the loop breaks and the warning path runs with no run id. HTTP statuses (403/429 and others) are decided before the no-response branch, so they are unaffected.
  • Wait cap. post-merge-dispatch now has WAIT_CAP: 180, and the test harness reads that cap from the yaml. The arithmetic in the comment holds: 127 s + 180 s + 170 s + about 20 s is about 8.5 minutes of the 15, leaving 6.5.
  • Tests. The stub gh writes stderr and exits non-zero when there is no status. The new cases cover DNS, refused connection and TLS handshake (resent), and reset, client timeout and empty stderr (not resent). The 181 s wait is refused and two 60 s waits are taken. The "no response" case in the old test was replaced, not dropped.
  • Changelog. The fragment has a patch bump, which fits a fix to CI behaviour.

Residual risk, not a defect: the resend check depends on Go's net/http error wording as gh prints it. If that wording changes, the step stops without resending, which is the safe direction.

Manifest items: none in this diff. Paved-path and closing-issue checks: there are no closing issues, only Refs #9297. No hold class applies.

@github-actions

github-actions Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

claude-security-review reviewed 053361defd03287b9abb5010f446b1a2e6693833: 0 finding(s), 0 as inline comments.

No security issues found in this pull request.

I read the full diff (.github/workflows/pr-merge.yml, .github/scripts/pr-merge/workflow.test.mjs, and a .changes entry) and the PR context. I also read the changed dispatch step in pr-merge.yml to follow how why, wait and code flow through the loop.

  • Stderr capture: gh's stderr now goes to $RUNNER_TEMP/dispatch-stderr and is echoed to the log. The file is written by the job itself under the runner temp directory. It holds only gh's own network error text, with no token or secret, because GH_TOKEN is passed through the environment and gh does not print it.
  • Workflow-command injection: $error (the last stderr line) now appears in a ::notice:: or ::warning:: line. It is only reached when there is no HTTP status, so the text comes from Go's net/http errors. An attacker cannot supply it, because nothing from a PR author or a response body reaches that branch. The message interpolation in the 403/429 branch is not new.
  • Retry narrowing: the resend condition is stricter than before. Only dial tcp and tls: handshake|first record errors are retried, so fewer duplicate dispatches can occur. The wait variable is empty in the new no-retry branch, so the [ -z "$wait" ] check breaks out of the loop. The loop does not retry by accident.
  • WAIT_CAP 300 to 180: this is a timing change only. It adds no new permissions, triggers or token scope.
  • Manifests: the diff touches no plugin manifests, trust-gate paths or instruction surfaces (CLAUDE.md, skill or agent bodies, hook allowlists), so there are no manifest <field> lines.
  • PR context: it contains no embedded instructions aimed at the review.

critical-findings: 0

@kyle-sexton
kyle-sexton added this pull request to the merge queue Oct 23, 2026
Merged via the queue into main with commit 4d3108b Oct 23, 2026
89 of 109 checks passed
@kyle-sexton
kyle-sexton deleted the fix/pr-merge-dispatch-slack branch October 23, 2026 07:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant