Problem
Stop update_pull_request's branch-update-from-base from crashing the safe_outputs job when the target PR merges out from under it. PR Sous Chef's safe_outputs job failed on 2 of 16 queued messages because both target PRs had already been merged (and their head branches deleted) in the ~60-90s between the agent job selecting them and the safe_outputs job processing its queue.
Affected Workflows and Run IDs
- PR Sous Chef 🍳 — §30764198337 (2026-08-02 19:54 UTC) —
agent job succeeded; safe_outputs job's "Process Safe Outputs" step failed with 2/16 messages failed.
Evidence
| Message |
PR |
Failure |
1/16 update_pull_request |
#49813 |
ERR_API: update pull request #49813 branch from base failed ... Original error: head ref does not exist — PR merged at 19:53:00 UTC, ~100s before this call at 19:54:40 UTC. |
9/16 update_pull_request |
#49814 |
Identical shape — head ref does not exist — PR merged at 19:53:19 UTC, ~85s before this call at 19:54:44 UTC. |
Both PRs are confirmed MERGED (verified via gh pr view), and their head branches are gone — standard auto-delete-on-merge behavior. The other 14 messages (add_comment ×2, resolve_pull_request_review_thread ×11, create_issue ×1) all completed successfully; this is not a broad outage, it's specifically the update_branch: true path racing against merge/branch-deletion.
Probable Root Cause
The agent job gathers a batch of PR candidates and queues safe-output messages (including update_pull_request with update_branch: true), but by the time the separate safe_outputs job actually executes them, PR state may have changed — in this case the PR was merged by something else in the interim, deleting its head branch. The handler doesn't check current PR state (open vs. merged/closed) before attempting the branch-from-base update, so a stale target throws a hard API error instead of degrading gracefully.
Specific Proposed Remediation
- Before calling the "update branch from base" API, check the PR's current
state/mergeable_state (or catch the specific "head ref does not exist" / 422 response) and treat a merged/closed/deleted-branch PR as a skip, not a failure — log it and continue processing the remaining queue.
- Do not let a single stale-target
update_pull_request failure mark the whole safe_outputs job as failed when the majority of queued messages succeeded — consider partial-success as a non-failing job outcome (or at minimum a distinct, lower-severity signal from a total handler crash).
Success Criteria / Verification
- Re-run or synthesize a repro where a target PR is merged between the
agent and safe_outputs jobs; confirm update_pull_request's branch-update step skips cleanly instead of throwing ERR_API.
- Confirm the
safe_outputs job no longer reports overall failure when only stale-target branch-updates are skipped and all other queued messages succeed.
Generated by 🔍 [aw] Failure Investigator (6h) · agent · 227.4 AIC · ⌖ 47.2 AIC · ⊞ 5.3K · ◷
Problem
Stop
update_pull_request's branch-update-from-base from crashing the safe_outputs job when the target PR merges out from under it. PR Sous Chef'ssafe_outputsjob failed on 2 of 16 queued messages because both target PRs had already been merged (and their head branches deleted) in the ~60-90s between theagentjob selecting them and thesafe_outputsjob processing its queue.Affected Workflows and Run IDs
agentjob succeeded;safe_outputsjob's "Process Safe Outputs" step failed with 2/16 messages failed.Evidence
update_pull_requestERR_API: update pull request #49813 branch from base failed ... Original error: head ref does not exist— PR merged at 19:53:00 UTC, ~100s before this call at 19:54:40 UTC.update_pull_requesthead ref does not exist— PR merged at 19:53:19 UTC, ~85s before this call at 19:54:44 UTC.Both PRs are confirmed
MERGED(verified viagh pr view), and their head branches are gone — standard auto-delete-on-merge behavior. The other 14 messages (add_comment ×2, resolve_pull_request_review_thread ×11, create_issue ×1) all completed successfully; this is not a broad outage, it's specifically theupdate_branch: truepath racing against merge/branch-deletion.Probable Root Cause
The
agentjob gathers a batch of PR candidates and queues safe-output messages (includingupdate_pull_requestwithupdate_branch: true), but by the time the separatesafe_outputsjob actually executes them, PR state may have changed — in this case the PR was merged by something else in the interim, deleting its head branch. The handler doesn't check current PR state (open vs. merged/closed) before attempting the branch-from-base update, so a stale target throws a hard API error instead of degrading gracefully.Specific Proposed Remediation
state/mergeable_state(or catch the specific "head ref does not exist" / 422 response) and treat a merged/closed/deleted-branch PR as a skip, not a failure — log it and continue processing the remaining queue.update_pull_requestfailure mark the wholesafe_outputsjob as failed when the majority of queued messages succeeded — consider partial-success as a non-failing job outcome (or at minimum a distinct, lower-severity signal from a total handler crash).Success Criteria / Verification
agentandsafe_outputsjobs; confirmupdate_pull_request's branch-update step skips cleanly instead of throwingERR_API.safe_outputsjob no longer reports overall failure when only stale-target branch-updates are skipped and all other queued messages succeed.