Repository navigation
fix(ci): bind pull_request_target safety runs to the PR head, not GITHUB_SHA - #2275
Conversation
…HUB_SHA The protected safety review compared GITHUB_SHA with the head_sha GitHub records for the workflow run. On pull_request_target GITHUB_SHA is a base-branch commit and the run's head_sha is the pull request head, so the comparison could not hold and every pull_request_target run since #1992 failed with 'workflow run SHA does not match the triggering event SHA'. For pull_request_target the run is now bound to the event's pull request head. issue_comment and merge_group keep the GITHUB_SHA binding. A missing or malformed SHA is an error.
Independent adversarial review: APPROVEFrom: Grok Verdict: APPROVE. The fix matches the observed failure. On What I checked (exact head 4bdd389, rebased on main 108ee9b)
P2: the published head can differ from the head that was evaluated (recommend a one-line guard). For P3 (latent, no merge-group runs in recent history):
Limits and CI: I did not run this on live GitHub. The checks here are unit tests and fakes. This PR's own |
Problem
The "Evaluate protected-path evidence" job has failed on every
pull_request_targetrun since the gate landed in #1992 on 2026-11-10 (none of the 192 runs since then succeeded). Every log sampled, from the first failure on 2026-11-11 to today, contains:_workflow_provenance_errorscomparesGITHUB_SHAwith thehead_shathat the Actions API records for the run. Onpull_request_targetthese are different commits by design:GITHUB_SHAis a base-branch commit and the run'shead_shais the pull request head. Run 44456030871 (#2270) shows it: the API reportshead_sha6cbbf43c8, the PR head, which is not onmain. The comparison holds forissue_commentandmerge_group, which is why comment-triggered runs pass.Fix
For
pull_request_targetthe run is bound to the pull request head in the event payload.issue_commentandmerge_groupkeep theGITHUB_SHAbinding. A missing or malformed SHA on either side is now its own error, so the check cannot be skipped by an empty value. Nothing else in the gate changes: the manifest, the review rules and the exact-base check are untouched.The old comparison was also wrong in the other direction. A
pull_request_targetrun whose recordedhead_shaequalledGITHUB_SHA(a commit other than the PR head) was accepted. The new testtest_pull_request_target_run_for_another_commit_failscovers that case.Evidence
Unit tests (
tests/test_protected_safety_review.py, 291 pass). The fixture uses three distinct SHAs for the PR head, the PR base and the tip ofmain. Three of the new tests fail against the script onmain.pull_request_targetGITHUB_SHAReplay against live data. The script ran locally with the real run IDs and PR metadata through a wrapper that only allows GET, so no check run was published.
mainNotes for the reviewer
pull_request_targetjob fails with the old error. The workflow runs the script from the PR base, so the fix takes effect for a PR once its branch is updated from amainthat includes it. Re-running an old job replays the old base and stays red.issue_commentpath, which publishes the verdict.protected-safety-reviewand this job are not in the required status checks formain._passed_pr_head_verdictchecks that a verdict run'shead_shais an ancestor ofmain. For a verdict produced bypull_request_targetthat is the PR head, so the merge-group path will refuse such verdicts. It fails closed and the merge queue ruleset is disabled.