fix(ci): stop backport PR-body updates failing on token scopes (and lying about conflicts) - #25226
Draft
AztecBot wants to merge 1 commit into
Draft
fix(ci): stop backport PR-body updates failing on token scopes (and lying about conflicts)#25226AztecBot wants to merge 1 commit into
AztecBot wants to merge 1 commit into
Conversation
…ying about conflicts)
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.
What went wrong
The backport of #25159 to
v5-nextwas reported in#backports(and on the PR) as❌ Failed to cherry-pick to v5-next due to conflicts. There was no conflict. From the backport run:The cherry-pick succeeded, the branch was pushed and #25224 was opened. What failed was the last step —
scripts/merge-train/update-pr-body.sh— becausegh pr editresolves the PR with a GraphQL query that asks for reviewer/team fields (login,name,slug). Those needread:org, andAZTEC_BOT_GITHUB_TOKENcarries onlyrepoandworkflow. Editing a PR body itself needs nothing beyondrepo.Because the whole step exited non-zero,
backport.ymltook the failure branch: it commented "conflicts" on the PR, pinged#backportswith "conflicts", and dispatched a ClaudeBox job to go resolve conflicts that do not exist.This is not specific to one PR. Every caller of
update-pr-body.shruns under the same token, so the same scope error is hitting merge-train and forward-port body updates too — e.g. theport-to-next-stagingupdate in run 31789678398 failed identically a few hours earlier, and thebackport-to-v5-next-stagingbody-update run failed again straight after. Staging PRs are left with theBody will be updated with commit list.placeholder instead of theBEGIN_COMMIT_OVERRIDEmarkers that drive the squashed commit message.The fix
scripts/merge-train/update-pr-body.sh— set the body withgh api --method PATCH repos/{owner}/{repo}/pulls/N -f body=...instead ofgh pr edit. Same REST-over-gh apistyle the script already uses two lines above to readbase.sha/head.sha, and it needs no scope the bot token lacks. This is the root-cause fix and it covers all three callers (backport staging,port_to_next.sh, and theMerge-Train PR Bodyworkflow).scripts/backport_to_staging.sh— a body-update failure no longer fails the backport. By that point the cherry-pick has landed, the branch is pushed and the staging PR exists; the caller treats any non-zero exit as a conflict, so failing here actively misreports a successful backport. It now warns and continues. The cherry-pick conflict path writesfailure_reason=conflictto$GITHUB_OUTPUT..github/workflows/backport.yml— the PR comment, the#backportsmessage and the ClaudeBox prompt now branch onfailure_reason. A real conflict reads exactly as before. Anything else says so ("not a cherry-pick conflict") and dispatches ClaudeBox to read the run log and find the real cause, rather than sending it hunting for conflicts.Fixing the token's scopes (adding
read:org) would also makegh pr editwork, but the API call doesn't need that access in the first place, so this keeps the bot token minimal.Testing
bash -non both scripts and a YAML parse of the workflow. The behaviour itself is only exercisable in CI: the next backport/port body update either sets theBEGIN_COMMIT_OVERRIDEmarkers or, if something else goes wrong, reports what actually failed. Note the changed workflow only takes effect for PRs whose base branch carries it, sov5-nextkeeps the old messaging until this is backported there.Created by claudebox · group:
slackbot· requested by Alex Gherghisan · Slack thread