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

[Bug]: submit reports success while leaving the lowest open PR based on a merged predecessor

Open Arvin132 opened this issue 1 month ago • 0 comments

Describe the bug

After the lower PRs in a stack have merged, gh stack submit recognizes that the lowest open PR still targets its merged predecessor instead of the trunk. It warns that it cannot update the base while stacked, but then exits successfully and says the stack is up to date. The PR retains its stale base and GitHub reports conflicts even though the branch merges cleanly into the current trunk.

Affected command

gh stack submit (with gh stack rebase completing successfully beforehand).

Environment

  • gh stack --version: gh stack version 0.2.1
  • gh --version: gh version 2.102.0 (2026-09-30)
  • Git: git version 2.56.0
  • OS: Fedora Linux 44, x86_64, kernel 7.2.9-201.fc44.x86_64
  • Shell: Bash 5.3.9

Steps to reproduce / observed state

Branch names and PR numbers below are anonymized. This was reproduced on an existing stack; the original sequence of operations that first left its remote base stale has not been isolated.

  1. The stack contains five PRs with trunk dev. The first three are merged; the last two remain open. The immediate predecessor of the lowest open PR was squash-merged into dev.
  2. Local stack metadata correctly marks all three predecessors merged and records the lowest open branch's base as the current dev commit. The next open branch is based on the lowest open branch.
  3. On GitHub, the lowest open PR still targets feature/merged-parent, the head branch of its merged predecessor, rather than dev.
  4. Run gh stack rebase. It completes without conflicts. An ordinary rebase onto dev also completes without conflicts.
  5. Run gh stack submit.
  6. Inspect the lowest open PR's base and mergeability again.

Expected behavior

Submitting should reconcile the lowest open PR's base with the first non-merged ancestor (dev), while preserving the open suffix of the stack.

If the stack API prevents that repair, the CLI should clearly report an unresolved synchronization failure and give actionable recovery instructions, rather than report the stack as up to date and exit successfully.

Actual behavior

submit detects the mismatch but skips updating the PR base because the PR is stacked. It exits with status 0 and reports success. A subsequent API check still returns the merged predecessor as baseRefName, mergeable: CONFLICTING, and mergeStateStatus: DIRTY.

Terminal output

Anonymized output from the reproduced gh stack submit run:

Checking stack state...
Skipping 3 merged branches
Pushing to origin...
⚠ PR #104 (https://github.com/OWNER/REPO/pull/104) has base "feature/merged-parent" (expected "dev") but cannot update while stacked
PR #105 (https://github.com/OWNER/REPO/pull/105) for feature/upper-layer is up to date
✓ Stack on GitHub is up to date with 5 PRs (stack #100)
✓ Pushed and synced 2 branches

Additional checks:

  • Local and remote heads for both open PR branches match.
  • The current local origin/dev commit matches the live remote dev commit.
  • git merge-tree --write-tree origin/dev HEAD succeeds without conflicts.
  • The same simulated merge against the merged predecessor produces eight conflicting files.
  • All three merged predecessor branches still exist on origin at their recorded commits, and all three remain present in local stack metadata with isMerged: true. They are absent as local branch refs.

Related issues and implementation

  • Related: #485 (stale stack base after a partial merge). This report specifically captures the CLI's inability to reconcile the stale PR target and its successful exit despite detecting the mismatch; no server-side rebase or merge-queue failure is asserted here.
  • Related: #524 (changing a stack's trunk). In this case the intended trunk has not changed; the remaining open PR should advance past its merged predecessor.
  • In cmd/submit.go at v0.2.1, the base mismatch path checks s.ID != "", emits the warning with the comment Stack API owns base relationships — can't update directly., and sets complete = false. The overall command still reports the stack as up to date in this reproduction.

Preflight checks

  • [x] Searched existing issues for duplicates.
  • [x] Reproduced on v0.2.1 and verified via the latest-release API that v0.2.1 is the current stable release. No extension upgrade was run because the installed version already matches it.

Arvin132 avatar Oct 19 '26 17:10 Arvin132