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

"Stacked PRs are not enabled for this repository" shown when the real problem is repository access (wrong active gh account)

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

@skarim 已经在做这个了。

开始于 2026年9月3日。

评估

这个 Issue 还没有评估数据。

描述

bug topic: enablement

What happened

Every gh stack command against our org repository failed with:

⚠ Stacked PRs are not enabled for this repository

…while the repository visibly had stacks in active use (colleagues' stacks in the PR list, and creating one through the web UI worked fine). We spent a good while chasing repository settings and extension versions before the actual cause surfaced: gh had two logged-in accounts in the keyring, and the active account had no access to the repository. gh auth switch to the right account fixed everything instantly:

$ gh auth status                      # two accounts; active one lacks access to the repo
$ gh api repos/<org>/<repo>/stacks    # → 404 for the active account, 200 for the other
$ gh stack submit --auto              # → "Stacked PRs are not enabled for this repository"
$ gh auth switch -u <other> && gh stack submit --auto   # → works, stack created

Why the message misleads

The extension maps every stacks API 404 to "feature not enabled" (warnStacksUnavailable in cmd/utils.go, behind all of its call sites). But observed behavior of the list endpoint on github.com says that interpretation is usually backwards — enablement is expressed by the array, and the 404 is about repository visibility:

Situation GET /repos/{owner}/{repo}/stacks
Readable repository, stacks in use 200, populated array
Readable repository, no stacks 200, []
Repository not visible to the token (private without access, or nonexistent) 404, generic {"message": "Not Found", …}

The 404 body is GitHub's deliberately anonymized not-found (private repositories are indistinguishable from nonexistent ones), so the response carries nothing that could be parsed to tell the cases apart — the only way to disambiguate is a second request.

Proposed fix

Probe repository readability when a stacks API call 404s (GET /repos/{owner}/{repo}): if the repository itself is not readable, report the access problem and point at gh auth status; only when the repository is readable keep the existing not-enabled message (as the fallback for deployments that gate the feature).

I have this implemented, tested (go build ./..., go test -race -count=1 ./... green, plus new coverage for both messages), and pushed — diff here:

https://github.com/github/gh-stack/compare/main...fix8ing:gh-stack:fix/404-warning-names-account-access

It adds ClientOps.RepoAccessible (REST GET /repos/{owner}/{repo} on the live client, default-accessible mock arm) and routes the single shared helper — renamed warnStacks404, since it no longer asserts one interpretation — through the probe. I could not open a PR directly (the org rejects PR creation from my token), so linking the branch here instead; happy to open it properly if you enable that, or feel free to take the diff as-is.

主要语言
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 摘要。