Repository navigation
[Buildkite] Fix fork PR builds: require full SHA, drop Events API gate - #1055
Merged
Merged
Conversation
The push-event gate added in #1044 can never pass for a fork PR: `GET /repos/<fork>/events` always returns `[]` even for active forks. This silently broke fork support that #1019 enabled. Fix: - Require the full 40-character SHA instead of >=7 chars. A full SHA is content-addressed, so the head-match check alone pins exactly what gets built -- no push-time proof needed. - Replace the `case` prefix match with exact string equality. - Add a copy-paste hint to the mismatch error so maintainers can recover from the merge-commit case (Update branch creates a new head SHA not visible in the commit list). - Remove HEAD_REPO_FULL from the jq tuple (only used by the deleted Events API block). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
PR #1044 added a push-time gate that queries the Events API to prove a commit predates the trigger comment. This broke the fork-PR support added in #1019:
GET /repos/<fork>/eventsalways returns[]for fork repositories — even when the fork is active andpushed_atreflects a recent push.The result is that every attempt to build a fork PR (like #1045) hits the fail-closed branch and exits 1:
A secondary issue (#1044's
case "$REQUESTED"\*prefix match): when the "Update branch" button creates a merge commit, the new HEAD SHA doesn't appear in the PR's commit list. Maintainers see2ae8498as the tip and use that, but the actual head iseac2822…. The error message printed the head SHA but gave no copy-paste hint.Fix
Require the full 40-character SHA instead of ≥7 chars.
A full 40-char SHA is content-addressed: naming it and verifying it equals the live PR head at workflow-resolution time pins the exact tree that gets built. A commit pushed after the comment has a different SHA and fails the head-match check — the push-time gate was only closing the abbreviated-SHA collision window (7 hex chars ≈ 28 bits, brute-forceable). Eliminating short prefixes removes that window entirely, making the Events API check redundant.
Changes:
{7,40}to exactly{40}with a trailing non-hex/end-of-string anchorcase "$REQUESTED"\*prefix match replaced with[ "$HEAD_SHA" != "$REQUESTED" ]exact equalityPUSHED_ATretry loop and all Events API code removed (also eliminates the--paginate | head -n1SIGPIPE hazard and the3 × sleep 1030-second penalty on every failure)HEAD_REPO_FULLremoved from theread -r/--jqtuple (was only used by the deleted block)Verification
main(issue_comment workflows run from the default branch).buildkite test this eac2822408d301a60cb89174a47f854550367236(re-read current head first withgh pr view 1045 --json headRefOid).refs/pull/1045/head.🤖 Generated with Claude Code