Merge API returns "New changes require approval from someone other than the last pusher" when the real block is an out-of-date branch #210883
Replies: 3 comments
|
💬 Your Product Feedback Has Been Submitted 🎉 Thank you for taking the time to share your insights with us! Your feedback is invaluable as we build a better GitHub experience for all our users. Here's what you can expect moving forward ⏩
Where to look to see what's shipping 👀
What you can do in the meantime 💻
As a member of the GitHub community, your participation is essential. While we can't promise that every suggestion will be implemented, we want to emphasize that your feedback is instrumental in guiding our decisions and priorities. Thank you once again for your contribution to making GitHub even better! We're grateful for your ongoing support and collaboration in shaping the future of our platform. ⭐ |
|
This is a known quirk in how GitHub evaluates branch protection rules during API merge operations. Why This HappensWhen a repository enables both:
The API merge endpoint ( Because strict status checks require that checks have passed against the latest integrated base, the server-side validator detects that the newest push onto Workaround & Best PracticeBefore attempting an API or CLI merge ( # Update PR branch with latest main
gh api -X PUT repos/{owner}/{repo}/pulls/{n}/update-branchOnce updated, the merge validation pipeline will pass and execute the merge without false approval rejections. |
|
fwiw the merge endpoint won't tell you which rule blocked it, but the PR object will. Read gh pr view 123 --json mergeStateStatus,reviewDecisionThe enum values are in the GraphQL docs: https://docs.github.com/en/graphql/reference/enums#mergestatestatus ( If it says gh pr update-branch 123 # add --rebase if you want a rebase instead of a merge commitREST equivalent: Agree the error text is wrong for this case, that part is on GitHub. Checking the state first at least stops the script from chasing the approval rule. |
Uh oh!
There was an error while loading. Please reload this page.
🏷️ Discussion Type
Bug
Body
What happened: On a protected main that requires the branch to be up to date before merging, plus "require approval of the most recent push", merging a PR whose branch was behind main failed with:
▎ New changes require approval from someone other than the last pusher. 2 of 2 required status checks are expected.
The same message came back from PUT /repos/{owner}/{repo}/pulls/{n}/merge and from gh pr merge --squash --admin (GraphQL mergePullRequest). The real cause was the out-of-date branch: after "Update branch" (rebase), the PR merged normally.
Expected: an error that names the actual blocker, for example "This branch is out of date with the base branch", as the web UI does. The message sent us looking at approval rules and an admin bypass, neither of which was the problem.
Repro: protected base branch with strict status checks and last-push approval enabled → open a PR → advance the base branch → merge through the API or gh pr merge without updating the branch.
All reactions