Repository navigation
Description
Describe the bug
gh pr merge <n> (no --admin) sends the merge when the pull request's mergeStateStatus is UNKNOWN. For a user who is a ruleset bypass actor, such as a repository admin with bypass_mode: always, GitHub then applies the bypass, so an unapproved pull request merges with no explicit opt-in. --admin exists so that a bypass happens only when it is asked for. On UNKNOWN, it happens without being asked for.
The cause is in the preflight. blockedReason in pkg/cmd/pr/merge/merge.go (v2.103.3) returns a reason only for BLOCKED, BEHIND and DIRTY, so canMerge passes for UNKNOWN. UNKNOWN is common: GitHub computes the state lazily, and the REST docs say a null mergeable means "GitHub has started a background job to compute the mergeability." In our repository, a single-PR read returned UNKNOWN for 8 of 8 open, unapproved pull requests that nobody had read recently. Three of them were still UNKNOWN after three minutes of re-reading.
In #13388 a maintainer wrote that refusing on BLOCKED by default is correct, because "bypassing ruleset protections requires an explicit action", and that the CLI shouldn't "silently bypass". Treating UNKNOWN as mergeable is a silent bypass for the same users.
Steps to reproduce the behavior
- On a repository with a ruleset that requires 1 approving review, add
bypass_actors: [{actor_type: RepositoryRole, actor_id: 5, bypass_mode: always}](the admin role). - As a repository admin, open a pull request with required checks passing and no reviews.
- Don't read the pull request for about 15 minutes, so its merge state is not computed.
- Run
gh pr merge <n> --squash, with no--admin.
Expected vs actual behavior
- Expected: gh refuses, as it does for
BLOCKED: "Pull request #n is not mergeable…", with the--adminand--autohints. - Actual: gh exits 0 and the pull request merges with
reviewDecision: REVIEW_REQUIRED. Read right after the merge,mergeStateStatusis stillUNKNOWN.
Suggested fix
When the preflight reads UNKNOWN, re-fetch for a bounded time. If the state is still UNKNOWN after that, refuse unless --admin (or --auto) is passed. That makes a bypass require the same explicit flag in every state.
Version
gh version 2.103.3 (2026-10-26), Linux.
Activity
cli-triage commentedon Nov 9, 2026
Reproducible on 2.103.3.
Using test data with a pull request whose
mergeStateStatuswasUNKNOWN:$ gh pr merge 123 --squash -R example.invalid/helloOutput: none. The command exited successfully and submitted the
PullRequestMergemutation without--admin.Exit status:
0(success). Expected: a refusal until the state resolves or an explicit bypass mode is selected.The latest release build, also 2.103.3, and source snapshot behaved the same. The test covers the CLI decision and request; it does not emulate GitHub's live ruleset enforcement.
Supporting reports
Duplicate analysis
Label reasoning
Reproduction log
Investigation notes
Generated by issue triage.
souvik-biswas-dev commentedon Nov 10, 2026
Hi, I'd like to work on this. My understanding is that
blockedReasonshould handleUNKNOWNby re-fetching for a short bounded period and, if it's stillUNKNOWN, refusing unless--adminor--autois passed. Is that the direction you'd prefer, and is there a preferred retry duration? Happy to add unit tests for the merge command.