Skip to content

[aw-failures] PR Sous Chef's update_pull_request branch-refresh crashes safe_outputs job on stale (already-merged) PR targets #49878

Description

@github-actions

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

  1. 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.
  2. 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 ·

  • expires on Aug 9, 2026, 5:34 PM UTC-08:00

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions