gh-stack icon indicating copy to clipboard operation
gh-stack copied to clipboard

Can't merge a stacked PR with no clear reason (all PRs show mergeable)

Open mr04vv opened this issue 4 months ago • 44 comments

Environment

  • develop branch are protected by a repository ruleset with:
    • require_last_push_approval: true
    • dismiss_stale_reviews_on_push: true
    • required status checks
    • No merge queue.

Reproduction

  1. Create a 3-level stack: develop <- A <- B <- C.
  2. Approve every PR after its latest push. All three show MERGEABLE / CLEAN / APPROVED, all checks green.
  3. On the top PR (C), the native GitHub "Merge stack (3)" box shows "Able to merge as a stack". Click it (merge method: Create a merge commit) and confirm.

Expected

All three PRs merge into develop, or the operation stops before anything merges.

Actual

  • UI shows "Merging stack… / 3 pull requests are being merged" briefly, then rolls back to "Able to merge as a stack". Nothing merges.
  • The PR event log records repeated auto-merge was automatically disabled — "Pull Request is not mergeable".

(In the image, the bottom PR has been merged, but the behavior remains the same even if it is not merged.) Image Image Image

Notes

  • Root cause not confirmed — the above are observed events only. One hypothesis is that merging the bottom PR moves the merge-base of the PR above it, invalidating its latest-push approval, but this has not been verified.
  • Reproduces without a merge queue, which differs from #174 (scoped to merge-queue branches, describes a hang rather than a rollback). Filing separately because the trigger and symptom differ; feel free to consolidate into #174 if preferred.

mr04vv avatar Jul 27 '26 06:07 mr04vv

Same issue with approval requirements. Following thread.

torsten-wolt avatar Aug 31 '26 08:08 torsten-wolt

Running into this today as well.

We have our dev branch which is linked up with our canary deployment in AWS. Every merge into dev triggers a canary build and deploy. Because we're using CDK and there are enough resources, this is taking tens of minutes.

As you might guess, the workaround of merging from bottom to top is really annoying and not an acceptable long term solution. If we're using stacks to mitigate the larger review bottleneck and burnout from increased LLM usage, we have to have the stack merge at once to trigger a single deploy action instead of waiting hours to clear our merge queue.

dallenbaldwin avatar Aug 31 '26 23:08 dallenbaldwin

Based on our experience and the other reports, I suspect this issue happens when you're not using merge queues. I merged a stack just fine on a repo using merge queues, but failed to on a repo without merge queues enabled.

  • other info: we have dismiss stale approvals enabled

joyhchen avatar Sep 02 '26 18:09 joyhchen

That's not something I would have thought of, in my case mentioned above, it was on repos with dismiss stale reviews on, merge queues off.

Can anyone else confirm if merge queues on, dismiss stale reviews on, is not affected by this behavior? In other words, are we closer to confirming that the exact repro is merge queues off, dismiss stale reviews on?

voidlily avatar Sep 02 '26 18:09 voidlily

Same here dismiss stale reviews and merge queues off.

torsten-wolt avatar Sep 03 '26 12:09 torsten-wolt

Ran into this on a 6-PR stack. Same thing as above: everything APPROVED and CLEAN, merge fails with "At least 1 approving review is required", nothing merges.

Turning off dismiss_stale_reviews_on_push in the ruleset fixed it. Identical stack, same approvals, no re-approval needed, that fixed it.

We had the "require_last_push_approval" set to false, so that one isn't needed to trigger it. dismiss_stale_reviews_on_push on its own is enough.

frte-aec avatar Sep 15 '26 12:09 frte-aec

We had the same issue, I can confirm that turning off dismiss_stale_reviews_on_push also solved it for us. I guess we can live without it 🤷‍♂️

Bazze avatar Sep 16 '26 16:09 Bazze

dismiss_stale_reviews_on_push is not the cause of the problem.

It only controls whether approvals are removed after a new push. It does not fix stacked branch relationships.

The PR is mergeable on GitHub, but gh-stack sees outdated parent commits after the branches were force-pushed. The dependent branches must be rebased or synchronized.

For stacked PRs, stale review dismissal should usually stay enabled because changes after a rebase need to be reviewed again.

kalileddendani avatar Sep 17 '26 08:09 kalileddendani

For us the solution was to disable Require approval of the most recent reviewable push. Dismiss stale pull request approvals when new commits are pushed alone was not working.

Image

kumboleijo avatar Sep 17 '26 09:09 kumboleijo

We had the same issue, I can confirm that turning off dismiss_stale_reviews_on_push also solved it for us. I guess we can live without it 🤷‍♂️

I'd push back on leaving it off. dismiss_stale_reviews_on_push is what keeps an approval tied to the commits that were actually reviewed. With it disabled, an approval survives every later push, so code can land on a protected branch that no one has looked at. That's a weaker control than most compliance baselines assume you have, and it applies to every PR in the repo, not only the stack you're trying to merge.

Turning it off to unblock a stack is reasonable as a one-off. Turn it back on the moment the stack is merged, and re-request review on anything that was pushed while it was off.

byronc-synthrics avatar Sep 19 '26 10:09 byronc-synthrics

Also reproducing this on September 23, 2026, with an eight-PR native stack in a private repository, using Squash and merge stack in the GitHub web UI.

Before the merge attempt, the UI showed every PR as Ready, with approvals and checks passing. Clicking Confirm squash and merge stack changed the status to “Merging…” and then failed with:

protected branch 'master' check failed: Waiting on code owner review from <org>/owners and/or <org>/qa.

Team names above are anonymized.

I've checked the API after the failed attempts:

  • All eight PRs reported reviewDecision: APPROVED and mergeStateStatus: CLEAN.
  • Each PR had a non-dismissed approval on its exact current head SHA, submitted on behalf of the QA code-owner team.
  • The reviewer’s QA team membership was active.
  • The relevant CODEOWNERS rule lists both teams on the same line:
    * @<org>/qa @<org>/owners
    
  • The stack’s top branch contained every lower PR head and was up to date with master.
  • All eight PRs remained open; nothing was merged.

Multiple attempts produced the same result: GitHub showed all eight PRs as ready, and the API reported APPROVED / CLEAN, but the stack merge failed with a missing code-owner review error. Nothing was merged.

isnoto avatar Sep 23 '26 11:09 isnoto

As a workaround, merging the PRs one by one works. But you will probably have to wait for the PR checks to run every time you merge one PR of the stack to merge the next one.

I use gh stack merge and then I make sure only the bottom PR is selected each time I want to merge a PR. Not ideal, but it's something.

adriancuadrado avatar Sep 23 '26 11:09 adriancuadrado

I hit the same issue in a 3 PR stack. I tried several different settings to try and isolate what was causing it

Every PR: APPROVED, CLEAN, MERGEABLE. Approval from a member of the code owner team, recorded onBehalfOf that team. No pending review requests. No review_dismissed events anywhere.

Squash and merge on the top PR:

Repository rule violations found
Waiting on code owner review from ORG/TEAM.

Ran the combinations:

dismiss_stale_reviews_on_push require_last_push_approval strict Result
true true true fails, "Waiting on code owner review"
true false true fails, same message
true false false fails, same message
false true true fails, different message
false false true merges

Same on classic branch protection and on a ruleset. strict made no difference.

Row 4 is where the error message changes to:

Waiting on 1 reapproval from someone other than the last pusher.
Review from REVIEWER is stale because it was submitted before the merge base changed.

Everything I'm seeing in the Github docs for stacks says we shouldn't see this and so I'm thinking there might be a bug in stacks or a new setting that should be added to allow some of these to be bypassed for stacks.

glitchedmob avatar Sep 23 '26 18:09 glitchedmob

If you have the right to enable the merge queue on the repo, do it, merge your approved stacked PR and remove it after and it will work. Your workflows need to be compatible with the merge queues but it works.

jebeaudet avatar Sep 23 '26 18:09 jebeaudet

I hit the same issue in a 3 PR stack. I tried several different settings to try and isolate what was causing it

Every PR: APPROVED, CLEAN, MERGEABLE. Approval from a member of the code owner team, recorded onBehalfOf that team. No pending review requests. No review_dismissed events anywhere.

Squash and merge on the top PR:

Repository rule violations found
Waiting on code owner review from ORG/TEAM.

Ran the combinations: dismiss_stale_reviews_on_push require_last_push_approval strict Result true true true fails, "Waiting on code owner review" true false true fails, same message true false false fails, same message false true true fails, different message false false true merges

Same on classic branch protection and on a ruleset. strict made no difference.

Row 4 is where the error message changes to:

Waiting on 1 reapproval from someone other than the last pusher.
Review from REVIEWER is stale because it was submitted before the merge base changed.

Everything I'm seeing in the Github docs for stacks says we shouldn't see this and so I'm thinking there might be a bug in stacks or a new setting that should be added to allow some of these to be bypassed for stacks.

Piling on here, I had the same error as @glitchedmob and confirmed that disabling dismiss_stale_reviews_on_push allowed the stack merge to complete. That does seem like unexpected behavior though because the reviews do not get dismissed if the PRs are merged one-by-one (i.e. there's no diff when the base changes). Hopefully the devs can fix it 🤞

gitjiggywithit avatar Sep 25 '26 17:09 gitjiggywithit

We are also facing this issue. All of the PRs within the stack are showing as Mergeable, but when attempting to merge the stack we are receiving the error:

Repository rule violations found Waiting on code owner review from team/team

joshbrw avatar Sep 28 '26 09:09 joshbrw

Same here on a 3 PR stack, squash only, no merge queue. The main ruleset has dismiss_stale_reviews_on_push, require_last_push_approval and code owner review on.

A couple of things I haven't seen in the thread yet:

  • The web UI did tell me why before I confirmed. "Confirm squash and merge stack (3)" showed "Review from X is stale because it was submitted before the merge base changed. Waiting on 1 reapproval from someone other than the last pusher." Nothing had been pushed since the approvals and main hadn't moved, so the approval on the top PR looks like it gets checked against main instead of the parent branch it was approved against.
  • Retargeting the top PR to main to merge everything as one squash is blocked too ("Cannot change the base branch because the pull request is part of a stack").
  • Merging bottom up works, but after each squash the next PR goes DIRTY because its branch still has the original commits of the PR that was just squashed. The squash tree was identical to the old head, so git merge -s ours origin/main on the next branch fixed it without changing any files. That's another push though, so each PR then needs a fresh approval.

tolzhabayev avatar Sep 29 '26 20:09 tolzhabayev

@imanmahjoubi is this going to get looked at?

benlangfeld avatar Sep 30 '26 16:09 benlangfeld

Hi ! I have the same issue: Stacked PR with a few PRs. Protected branch with:

 - required_approving_review_count : 2
 - squash_merge: true

Two PRs are ready to merge, both got 2 approvals. I click Squash and merge and it fails with At least 2 approving reviews are required by reviewers with write access.. Also fails with the same message on CLI.

I can merge it one after the other manually, and it succeds. However the stacked PR merge fails.

Gu1nness avatar Oct 01 '26 07:10 Gu1nness

My team has the same issue and we do not want to disable "Dismiss stale pull request approvals".

ValentinRLL avatar Oct 01 '26 13:10 ValentinRLL