link assumes 'main' as the bottom PR's base instead of the repo default branch
Environment
- gh 2.96.0 (2026-07-02), gh-stack v0.0.4, git 2.46.1, macOS 26.6
- Repo default branch is
develop. There is nomainbranch.
Summary
gh stack link tried to retarget the bottom PR's base to main, a branch that does not exist in this repo. It looks like link assumes main rather than reading the repository's default branch.
GitHub rejected it, so nothing broke here. On a repo that does have a main alongside a different default, this would silently retarget the bottom of the stack to the wrong trunk.
Repro
# PR A: feature/a -> develop (develop is the repo default branch)
# PR B: feature/b -> feature/a
# PR C: feature/c -> feature/b (created with `gh pr create --base feature/b`)
gh stack link A B C
Checking existing stacks...
⚠ failed to update base branch for PR #A to main: HTTP 422: Validation Failed
PullRequest.base is invalid
✓ Updated stack to 3 PRs
PR #A's base was and should remain develop. Confirmed afterwards that all three bases were untouched.
Expected
link should leave the bottom PR's base alone, or read the repository's default branch rather than assuming main. The init command already takes --base; link has no equivalent.
Related
Reached link because there is no way to add an existing branch to an existing stack. gh stack init refuses with branch "<name>" already exists in a stack, and gh stack add only creates a new branch rather than adopting one that already has commits. The workaround was gh pr create --base <parent> followed by gh stack link. An add --existing, or letting init re-adopt, would avoid sending people through link for this.
This was fixed in #265 and released in v0.1.0