Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

HTTP 422 when resubmitting a stack with a new bottom branch after merge

未关闭
#428 0 条评论 3 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
55/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
冷清
技术栈
github, go
领域
api, cli

调研方向

gh stack submit 的覆盖流程以及对 /repos/org-name/repo-name/stacks/656/unstack 的堆栈替换请求开始;重现合并 branch-a、添加 branch-d 以及重新提交的顺序。完成的标准是现有堆栈可以在不出现 HTTP 422 的情况下被替换,并且 GitHub 反映出 branch-dbranch-bbranch-c

由索引模型根据 Issue 内容生成。

描述

bug topic: cli - submit

Summary

When using gh stack, submitting a stack fails if the bottom branch in the stack has been merged and a new branch is subsequently added below the remaining stack.

gh stack submit detects that the local stack has changed and offers to overwrite the existing stack on GitHub, but the overwrite fails because the existing GitHub stack still contains the previously merged branch.

Reproduction

Start with a stack containing three branches:

main
 │
 ▼
branch-a
 │
 ▼
branch-b
 │
 ▼
branch-c

Submit the stack with gh stack submit.

At this point, the GitHub stack looks like:

main
 │
 ▼
branch-a
 │
 ▼
branch-b
 │
 ▼
branch-c
1. Merge the bottom branch

Merge the PR for branch-a into main.

The remaining stack is now effectively:

main
 │
 ▼
branch-b
 │
 ▼
branch-c
2. Add a new branch below the stack

Create branch-d from main and add it to the bottom of the local stack.

The local stack is now:

main
 │
 ▼
branch-d
 │
 ▼
branch-b
 │
 ▼
branch-c

So the local stack has changed from:

main
 │
 ▼
branch-a
 │
 ▼
branch-b
 │
 ▼
branch-c

to:

main
 │
 ▼
branch-d
 │
 ▼
branch-b
 │
 ▼
branch-c
3. Submit the modified stack

Run:

gh stack submit

gh stack detects that the local stack has been modified and asks:

✗ a modify was completed but the stack has not been submitted yet

? The local stack has been modified. Overwrite the existing stack on GitHub? Yes

The submit then fails with:

⚠ Failed to delete existing stack: HTTP 422: Pull request #650 cannot be removed from this stack
(https://api.example.ghe.com/repos/org-name/repo-name/stacks/656/unstack)

Expected behavior

gh stack submit should reconcile the local stack with the existing GitHub stack.

The following workflow should be supported:

Create stack
    ↓
Submit stack
    ↓
Merge bottom branch
    ↓
Add a new branch below the remaining stack
    ↓
Submit stack again

After submitting, the GitHub stack should reflect:

main
 │
 ▼
branch-d
 │
 ▼
branch-b
 │
 ▼
branch-c

The previously merged branch-a should no longer be part of the stack.

Actual behavior

The submit operation attempts to overwrite the existing GitHub stack, but fails while trying to remove the existing stack:

HTTP 422: Pull request #650 cannot be removed from this stack

This prevents the modified local stack from being submitted.

Possible cause

It appears that merging the bottom branch leaves the existing GitHub stack in a state that cannot subsequently be replaced when a new branch is inserted below the remaining stack.

The problematic sequence appears to be:

Initial GitHub stack:

main
 │
 ▼
branch-a
 │
 ▼
branch-b
 │
 ▼
branch-c

       │
       │ merge branch-a
       ▼

Local/GitHub stack:

main
 │
 ▼
branch-b
 │
 ▼
branch-c

       │
       │ add branch-d below branch-b
       ▼

Local stack:

main
 │
 ▼
branch-d
 │
 ▼
branch-b
 │
 ▼
branch-c

       │
       │ gh stack submit
       ▼

HTTP 422 while removing the existing stack

The error references the top branch (branch-c / its PR), even though the structural change is at the bottom of the stack.

This may indicate that the stack replacement/unstack operation is trying to remove or reorder PRs in an order that is invalid after the original bottom PR has already been merged.

Environment

  • gh stack: 0.1.0
  • OS: macOS

Minimal reproduction

Initial:

main
└── branch-a
    └── branch-b
        └── branch-c

Merge branch-a:

main
└── branch-b
    └── branch-c

Add branch-d below branch-b:

main
└── branch-d
    └── branch-b
        └── branch-c

gh stack submit
→ HTTP 422

The expected result is that the final stack is successfully updated to:

main
└── branch-d
    └── branch-b
        └── branch-c
主要语言
Go
星标
1.5k
派生
73
平均合并
1 天 8 小时
30 天内合并 PR
7

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

github/gh-stack 的其他 Issue

查看 github/gh-stack 的全部 Issue

相似的 Issue

更多 Go Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。