Repo rulesets deny me from merging PR into protected branch in usual way. #113172
Replies: 7 comments 6 replies
|
When you set up a branch protection rule in a GitHub repository, especially one that restricts updates to the branch (like requiring status checks to pass before merging), it's designed to enforce those rules for all users, including repository owners and those with administrative permissions. The "Restrict updates" rule helps ensure that the code meets certain standards or passes specific checks before it's merged into the protected branch. However, GitHub provides an option for users with administrative privileges or those explicitly listed to bypass these branch protection rules when merging pull requests. This is likely the "Merge without waiting for requirements to be met (bypass branch protections)" checkbox you're seeing. This feature is intended as a safety valve for situations where an exception to the rule is warranted, allowing for flexibility in managing the repository while still enforcing code quality and review standards as the general rule. Seeing a warning or notification about "Merging is blocked" is expected behavior under branch protection rules, even for repository owners or those with permissions to bypass these rules. This notification serves as a reminder of the protections in place and ensures that the decision to bypass them is made consciously. The behavior you're experiencing, where you see a notification but also have the option to bypass the branch protections, aligns with GitHub's design to balance between enforcing code quality and providing flexibility in repository management. It's important to use the bypass option judiciously, as it overrides the safeguards you've put in place. If your expectation was for certain users or the repository owner to merge PRs without seeing this warning at all, GitHub's current implementation might not directly support that workflow without displaying the warning. The platform's approach aims to maintain awareness and caution whenever branch protections are being overridden. For detailed guidance or if you're looking for specific functionalities around branch protection and merging behavior that aren't currently supported, reaching out to GitHub Support or suggesting features through the GitHub Community Forum could provide more tailored assistance or lead to potential updates in future platform enhancements. |
|
To following on this, I seeing a similar message in the context of this pull-request: ImagingDataCommons/idc-index-data#9 That said, I am not able to understand why as it seems all checks seems to be passing. For context:
Notes |
|
Just following on from this. I understand that PRs are being blocked when the 'Restrict Update' rule is set. I currently have local git hooks to check for commits to these protected branches but without adding users to the bypass list is there no way to stop direct pushes to branches whilst allowing PRs to be merged when they follow the correct PR process? I know force commits can be disabled but it seems insane that direct pushes can't be stopped on the github side and I have to rely on local git hooks to catch this locally. |
|
My workaround to use rulesets but enforce who can merge PRs without having to bypass rules was to create two rulesets. One ruleset includes all my intended rules including "Restrict updates" and a second ruleset that only has "Restrict updates" applied, but with repo admins added to the bypass list "Exempted from rules". Now only repo admins can merge PRs without bypassing rules as intended, but I suppose this also means repo admins are unrestricted from pushing to the target branch(s)? 🤷♂️ |
|
+1, hitting this too — and can confirm the root cause with a clean test. We have a repository ruleset (require_code_owner_review + required_approving_review_count) with a GitHub App added as a bypass_actors entry (Integration type, tried both bypass_mode: always and pull_request). The app auto-approves and calls |
|
Follow-up with concrete repro data, in case it helps someone on the GitHub side pick this up — this is fully reproducible on our end: Setup: Repository ruleset, Test A — PR with all checks green, approved by the bypass-listed App, auto-merge enabled via Test B — same PR conditions, but instead of No special override flag, no admin privileges beyond being a listed bypass actor. Result: merged instantly, no error. So the bypass grant itself is real and correctly enforced by the synchronous merge endpoint — it's specifically the async/deferred auto-merge completion path that never re-checks Workaround for anyone stuck on this: have your automation call the merge endpoint directly (Test B) instead of relying on |
|
I had the same problem, but it turns out that it was a PEBCAK. Too many rules. After simplification it works as expected. |






When you set up a branch protection rule in a GitHub repository, especially one that restricts updates to the branch (like requiring status checks to pass before merging), it's designed to enforce those rules for all users, including repository owners and those with administrative permissions. The "Restrict updates" rule helps ensure that the code meets certain standards or passes specific checks before it's merged into the protected branch.
However, GitHub provides an option for users with administrative privileges or those explicitly listed to bypass these branch protection rules when merging pull requests. This is likely the "Merge without waiting for requirements to be met (bypass bra…