Skip to content

[Bug]: Stack merge via merge-async lands the trunk merge commit, then fails with "Could not create merge commit" and leaves upper PRs open #626

Open

Description

@tomassvatek

Describe the bug

Merging a native stack through the asynchronous merge API landed the code on the trunk, then failed partway through. GitHub created one merge commit on the trunk that merges the top PR's head, so every commit in the stack reached the trunk. Then it marked only the two lowest PRs as merged and finished with failed: Could not create merge commit. The other six PRs stayed open even though all their commits were already on the trunk, and there was no supported way to mark them merged afterwards.

Affected command

None. The merge was a direct REST call: PUT /repos/{owner}/{repo}/pulls/{top}/merge-async with merge_method: merge and merge_action: direct_merge. Before that, gh pr merge on the bottom PR was refused with "This pull request is part of a stack and must be merged using the asynchronous merge REST API".

gh-stack version

v0.1.0 installed, but it was not used for the merge.

GitHub CLI version

gh version 2.97.0 (2026-07-31)

Operating system

macOS 26

Shell

zsh

Steps to reproduce

Private organization repository, no merge queue on the trunk, no required reviews, merge commits allowed, "Automatically delete head branches" on.

  1. Have an 8-PR native stack, trunk <- #1 <- #2 <- ... <- #8. Each PR was clean and mergeable, its required checks passed on its current head, and every branch contained the branch below it.
    • Before merging, each branch had been rebased and force-pushed several times, including one rebase of the whole stack onto the latest trunk. Each push used --force-with-lease.
  2. Call PUT /pulls/{#8}/merge-async with sha set to Docs site for stacks #8's head, merge_method: merge and merge_action: direct_merge. Response: 202, status: pending.
  3. Poll GET /pulls/{#8}/merge-async/{uuid}.

Expected behavior

Either every PR in the stack is merged and marked merged, or nothing changes, since stack merges are described as atomic.

Actual behavior

Possibly related: #457 (open stack PRs when the trunk already has the merge commit), #485 (stale stack base after a partial merge) and #581 (dependent PR left on a merged branch and not retargeted). Here GitHub's own stack merge created the trunk commit and then failed to finish.

Terminal output

$ gh pr merge {#1} --merge --match-head-commit <sha>
GraphQL: This pull request is part of a stack and must be merged using the asynchronous merge REST API. (mergePullRequest)

$ gh api -X PUT repos/{owner}/{repo}/pulls/{#8}/merge-async -f sha=<head sha> -f merge_method=merge -f merge_action=direct_merge
HTTP/2.0 202 Accepted
{"status":"pending","details":{"message":"Merge request enqueued.","merge_method":"merge","merge_action":"direct_merge", ...}}

$ gh api repos/{owner}/{repo}/pulls/{#8}/merge-async/<uuid>
{"status":"failed","details":{"message":"Could not create merge commit", ...}}

$ gh pr edit {#3} --base <trunk>
GraphQL: Cannot change the base branch because the pull request is part of a stack. (updatePullRequest)

The merge request UUIDs and the repository are available to GitHub staff privately on request.

Preflight checks

  • I searched the existing issues for duplicates.
  • I ran gh extension upgrade stack and reproduced this issue on the latest stable release. (Not applicable: the merge ran server-side through the REST API, not through the extension.)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions