fix(ci): fall back to native auto-merge when a direct merge is refused - #283
Merged
Conversation
Three consecutive sweeps read #278 and #282 as MERGEABLE/CLEAN, announced the merge, and were refused: X Pull request #278 is not mergeable: the base branch policy prohibits the merge. There is no such policy. main has branch protection with every option disabled, no rulesets, no CODEOWNERS, no required checks and no required reviews. Throughout the same window the bot merged #225, #226, #279 and #280 without trouble — including #225/#226, which modify .github/workflows/, so this is not the token's workflows scope either. The refusal is gh's client-side precheck reading the mergeStateStatus that GITHUB_TOKEN sees, which is not the one a PAT sees — nothing this script can inspect its way around. So log both what we saw and delegate: native auto-merge is GitHub performing the merge itself, and does not go through that precheck. It is the escape hatch gh names in its own error message. Still one car per sweep — the fallback is followed by the same `break`, so at most one PR per sweep is handed over, and the green-base guard is unchanged. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This was referenced Aug 7, 2026
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.
Symptom
Three consecutive sweeps read #278 and #282 as
MERGEABLE/CLEAN, announced the merge, and were refused:Both PRs sat green and unmergeable while the queue drained around them.
There is no such policy
Checked, all of it:
mainreviewDecisionAnd it is not the token's
workflowsscope — the same bot merged #225 and #226 today, both of which modify.github/workflows/:What it actually is
gh pr mergerefuses client-side based on themergeStateStatusthatGITHUB_TOKENsees, which is not always the one a PAT sees. The script cannot inspect its way out of a disagreement it is on the wrong side of.So: log what we saw (
mergeable/mergeStateStatusnow appear on the merge line), then delegate to native auto-merge — GitHub performing the merge itself, which does not go through that precheck. It is the escape hatchghnames in its own failure message.Discipline preserved
The fallback is followed by the same
break, so at most one PR per sweep is ever handed over, and the green-base guard is untouched.🤖 Generated with Claude Code