Repository navigation
Description
Description
When the calling user has ruleset bypass authority that would resolve a mergeStateStatus: BLOCKED PR (e.g., via bypass_actors with bypass_mode: pull_request matching the user's RepositoryRole), gh pr merge refuses at pre-flight rather than attempting the merge. The error offers --admin
or --auto as escape hatches, neither of which fits what the user actually needs.
The underlying REST API merge endpoint (PUT /repos/{owner}/{repo}/pulls/{n}/merge) does engage bypass correctly when called directly. So the gap
is in gh pr merge's pre-flight logic, not in the API.
For repositories using rulesets with bypass_actors as a deliberate design choice — codifying who can self-merge per design intent rather than via
admin override — this means every PR by a bypass-eligible user falls back to --admin. Bypass becomes configured-but-unused; admin overrides
accumulate as if the rule were misconfigured.
Reproduction
-
Configure a ruleset on
mainwithrequired_approving_review_count: 1and:"bypass_actors": [ { "actor_id": 5, "actor_type": "RepositoryRole", "bypass_mode": "pull_request" } ]
-
As the bypass-eligible user (here, a repo admin — RepositoryRole=5), open a PR. The PR will have:
- mergeStateStatus: BLOCKED
- reviewDecision: REVIEW_REQUIRED
- reviewCount: 0 -
Confirm bypass eligibility — GET /repos/{owner}/{repo}/rulesets/{id} returns:
"current_user_can_bypass": "pull_requests_only"
4. Try gh pr merge:
$ gh pr merge <PR#> --squash --delete-branch
X Pull request /#<PR#> is not mergeable: the base branch policy prohibits the merge.
To have the pull request merged after all the requirements have been met, add the --auto flag.
To use administrator privileges to immediately merge the pull request, add the --admin flag.
5. Call the REST merge endpoint directly — succeeds, bypass engages:
$ gh api repos///pulls/<PR#>/merge -X PUT -f merge_method=squash
{"sha":"...","merged":true,"message":"Pull Request successfully merged"}
Expected behavior
gh pr merge should detect bypass eligibility before refusing. Two reasonable fix shapes:
- Conservative: if mergeStateStatus: BLOCKED but current_user_can_bypass indicates bypass-via-pull_request, attempt the merge — the API will engage
bypass automatically. - Simpler: always attempt the API merge and let GitHub's response be authoritative. Bypass engages or it doesn't, and either way the API's response is
meaningful (success, or a real error worth surfacing). The current pre-flight refusal pre-empts an outcome the API would have produced correctly.
Actual behavior
gh pr merge refuses based purely on mergeStateStatus: BLOCKED without checking bypass authority. Suggested escape hatches:
- --admin works but is structurally the wrong fit — admin override loudly overrides a rule that the user is in fact authorized to bypass per design.
- --auto doesn't engage bypass either; auto-merge waits for the original blockers to resolve, which (with bypass authority) won't happen organically.
gh version
gh version 2.90.0 (2026-04-16)
Why this matters
Rulesets with bypass_actors are a natural way to encode "who can self-merge" per design intent for repos with mixed-author models (e.g., bot-authored
PRs requiring review; human-authored PRs not). When gh pr merge doesn't respect bypass, the design becomes ceremony that doesn't deliver: operators
fall back to --admin per PR, repeated admin override erodes the rule's authority, and the codified bypass goes unused.
Current workaround: shell wrapper around gh api .../pulls/{n}/merge -X PUT. Functional but loses the ergonomic value of gh pr merge (mergeStateStatus
visibility, branch deletion semantics, default merge method from repo settings, etc.).
Upstream context
- GitHub Rulesets REST API: https://docs.github.com/en/rest/repos/rules
- current_user_can_bypass field: returned on GET /repos/{owner}/{repo}/rulesets/{id} — could serve as the pre-flight signal gh pr merge is currently
missing
EOF
Activity
babakks commentedon May 15, 2026
Thanks for the detailed write-up, @dadcoachengineer! 🙏
I looked into this and agree there's a gap here, though I see it as a missing feature rather than a bug in the existing preflight logic. Here's my thinking:
When a PR has
mergeStateStatus: BLOCKED, I think it's correct forgh pr mergeto refuse by default. Even on the web UI, bypassing ruleset protections requires an explicit action (the "bypass rules" checkbox). I'd want the CLI to follow the same pattern rather than silently bypassing rules.It's worth noting that
--adminis purely a client-side confirmation, similar to the checkbox on the web UI. It doesn't send anything special to the API or merge with elevated permissions. It just tellsghto skip its own preflight check and let the server decide whether the caller actually has the authority to merge. So in practice,--adminalready works for your use case. That said, I understand it feels like the wrong tool for the job when you're exercising ruleset bypass authority rather than admin override.I see this report as an opportunity to improve things on two fronts: first, better UX by offering a separate, less confusing flag for ruleset bypass; and second, keeping merge queue behavior distinct from other rulesets. Although merge queues are technically enforced via rulesets,
gh pr mergealready treats them as a separate concern, and I think that separation is worth preserving.What I'm considering is a new
--bypass-rulesflag that would:BLOCKEDpreflight check (similar to how--adminworks today)--admin, which bypasses both rulesets and the merge queue)This would give bypass-eligible users a clear, intentional way to merge without reaching for
--admin, which carries broader semantics (it also skips the merge queue entirely and performs a direct merge).I'll label this as an enhancement and keep it open for tracking. No timeline to share right now, but I appreciate you laying out the problem so clearly.
github-actions commentedon May 15, 2026
Thank you for your issue! We have categorized it as an enhancement (feature or improvement) request, and it has been added to our backlog. In doing so, we are not committing to implementing this feature at this time, but, we will consider it for future releases based on community feedback and our own product roadmap.
Unless you see the help wantedContributions welcome
label, we are not currently looking for external contributions for this feature.
If you come across this issue and would like to see it implemented, please add a thumbs up! This will help us prioritize the feature. Please only comment if you have additional information or viewpoints to contribute.
babakks commentedon May 15, 2026
Here are my suggested changes for the new
--bypass-rulesflag. Note that both--adminand--bypass-rulesare purely client-side overrides and there's no API-level concept/input for them.New
--bypass-rulesflag, off by default.Flag docs: "Bypass branch rulesets to merge a pull request, except merge queue constraints"
For context on how
pr mergehandles merge queues today: when a branch has a merge queue enabled,pr mergeskips the BLOCKED/BEHIND preflight entirely. If required checks have passed, the PR is added to the queue; if not, auto-merge is enabled. The--bypass-rulesflag does not change this behavior.Update
--adminflag docs from the current: "Use administrator privileges to merge a pull request that does not meet requirements", to something like: "Bypass branch rulesets to merge a pull request, including merge queue constraints"--bypass-rulesis mutually exclusive with--admin,--auto, and--disable-auto(same as--adminis today).Update the preflight error message (currently shown when
mergeStateStatusisBLOCKED) to mention--bypass-rulesas an option alongside--admin. Differentiate the two hints:--bypass-rules: for users with ruleset bypass authority.--admin: for admins; also bypasses merge queue constraints.When
--bypass-rulesis used on a queue-enabled repo, it is effectively a no-op (the queue path already skips theBLOCKEDpreflight). No error, no special handling needed.Please share your thoughts, @BagToad and @williammartin, so that we can put down the A/C for this change.
ci(auto-merge): merge via REST API to engage ruleset bypass (#226)
Merge bump PRs via REST endpoint so ruleset bypass engages (#10)
jgsuess commentedon Jul 23, 2026
+1, hitting this too. We're running Dependabot auto-merge via
gh pr merge --auto --squashfrom a GitHub App identity that is a configuredbypass_actorsentry on a repository ruleset requiring code owner review. The client-side mergeability pre-check refuses the merge even though the underlying RESTPUT /pulls/{n}/mergeendpoint honors the bypass and merges immediately when called directly. This is currently blocking essential Dependabot automation across multiple repos for us — would really appreciate a fix or at least an official workaround/flag to skip the client-side check for bypass-eligible actors.jgsuess commentedon Jul 23, 2026
Follow-up: worth distinguishing two related-but-separate bugs here, since I've now also filed detailed repro on the platform side. This CLI issue is about
gh pr merge's client-sidemergeStateStatuspre-check refusing to attempt a merge for a bypass-eligible actor. Separately, there's a deeper platform bug where even GitHub's own async auto-merge completion (viaenablePullRequestAutoMerge, not justgh) never re-checksbypass_actorswhen it finally executes the merge — confirmed via a clean 10-minute unattended test, with a direct synchronousPUT .../mergecall succeeding instantly on the same PR. Details and repro steps posted at https://github.com/orgs/community/discussions/162623 and https://github.com/orgs/community/discussions/190610 in case that's useful context for whoever picks this up.fix(ci): merge the scheduled results PR with --admin (#216)
reporulez#68: validate a ruleset's required fields before it is ever …
Fix the merge command and close review gaps found in an external review
keapa22 commentedon Nov 12, 2026
#13388