Skip to content

[Bug]: modify gets stuck in pending_submit after inserting a branch with no commits below a PR branch #648

Backlog

Description

@shon-mineyoshi-safie

Describe the bug

After gh stack modify inserts a new branch with no commits of its own below a branch that already has a PR, the modify session stays in pending_submit. modify and modify --abort are both blocked, and the only way out is a successful submit. But submit cannot open a PR for the new branch because it has no commits, so the session can never be cleared. The only escape is deleting .git/gh-stack-modify-state by hand.

Related: #433 (same dead end, triggered by a failed unstack) and #629 (same error message).

Affected command

gh stack modify / gh stack submit

gh-stack version

gh stack version 0.3.0

GitHub CLI version

gh version 2.102.0 (2026-09-30)

Operating system

macOS 26.6.2

Shell

zsh

Steps to reproduce

  1. Have a stack that has already been submitted, so a remote stack exists: trunk → A (PR) → B (PR)
  2. Run gh stack modify, insert a new branch C above A (so C points at A's tip and has no commits of its own), and apply with Ctrl+S.
  3. Run gh stack modify again → blocked.
  4. Run gh stack modify --abort → only prints a hint to run submit.
  5. Run gh stack submit → cannot create a PR for C, and the session is kept.

Expected behavior

Any of these would avoid the dead end:

  • modify warns about, or refuses, inserting a branch with no commits below a branch that has a PR, in a stack that already exists on GitHub
  • submit can finish a pending modify while skipping branches that cannot have a PR yet
  • modify --abort can roll back a session in pending_submit using the saved snapshot

Actual behavior

  1. Inserting C changes B's PR base to C, so affectsBranch returns true and finishApply saves the session as pending_submit (apply.go#L244, actions.go#L187).
  2. modify refuses to run while the session is in pending_submit (modify.go#L414-L418), and --abort does not restore anything (modify.go#L263-L267).
  3. submit cannot create a PR for C (no commits between A and C), so not every PR is submitted and the session is kept (submit.go#L302-L309).
  4. Before failing, that submit has already unstacked the old remote stack and changed B's PR base to C. The remote state has partly changed while the local session is still stuck.

Workaround: back up and delete .git/gh-stack-modify-state, fix the order and base/head entries in .git/gh-stack by hand, move the branch with git branch -f, and change B's PR base back with gh pr edit --base.

Terminal output

$ gh stack modify
✓ Inserted C after A

✓ Stack modified successfully
  Inserted: C

Run `gh stack submit` to push your changes and update the stack of PRs on GitHub
$ gh stack modify
✗ a modify was completed but the stack has not been submitted yet
Run `gh stack submit` to push changes and recreate the stack on GitHub
$ gh stack submit 
Checking stack state...
? The local stack has been modified. Overwrite the existing stack on GitHub? Yes
✓ Cleared existing stack on GitHub
Pushing to origin...
PR for A is up to date
⚠ failed to create PR for C: creating PR: GraphQL: No commits between A and B (createPullRequest)
✓ Updated base branch for PR (PR number of B) to C
✗ modify is not fully submitted; recovery state was retained
Finish submitting all remaining PRs, then retry `gh stack submit`

Preflight checks

  • I searched the existing issues for duplicates.
  • I ran gh extension upgrade stack and reproduced this issue on the latest stable release.

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

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions