gh stack link --remote <fork> queries the fork’s parent repository
Ninguém assumiu esta issue ainda.
Avaliação
- Dificuldade
- 3/5
- Tempo estimado
- 1-2 dias
- Facilidade para iniciantes
- 68/100
- Tipo de issue
- Bug
- Clareza
- Razoavelmente clara
- Status de atividade
- Ativa
- Stack de tecnologia
- git, github, go
- Domínio
- cli, developer-experience
Direção de pesquisa
Comece reproduzindo gh stack link --base main --remote fork --open <first-pr> <second-pr> na configuração de fork multi-remote e, em seguida, inspecione a resolução do repositório e o estado de .git/gh-stack. Considera-se concluído quando o comando usa o endpoint do fork e sinais conflitantes do repositório falham antes de uma solicitação à API com um erro de seleção claro; adicione um teste de regressão para este cenário.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
Summary
In a fork clone with separate upstream and fork remotes, gh stack link --remote fork queries the stack API for the upstream parent repository instead of the selected fork.
This prevents linking existing PRs when access to the parent is restricted, even though the authenticated user can access the fork and all PRs being linked have both their base and head repositories in the fork.
This appears related to #381, but that report covers gh stack submit selecting origin in a multi-remote clone. This reproduction covers gh stack link, has no origin remote, and shows the extension selecting a fork's parent despite an explicit --remote, remote.pushDefault, and gh-resolved repository.
Environment
gh version 2.100.0 (2026-09-03)gh stack/github/gh-stackv0.1.1- Repository:
<fork-owner>/<repository>, a fork of<upstream-owner>/<repository> - Two existing PRs whose base and head repositories are both the fork
Repository configuration
$ git remote -v
fork git@github.com:<fork-owner>/<repository>.git (fetch)
fork git@github.com:<fork-owner>/<repository>.git (push)
upstream git@github.com:<upstream-owner>/<repository>.git (fetch)
upstream no_push (push)
$ git config --get remote.pushDefault
fork
$ git config --get remote.fork.gh-resolved
<fork-owner>/<repository>
$ gh repo set-default --view
<fork-owner>/<repository>
The local .git/gh-stack state was initialized with the parent repository despite this configuration:
{
"schemaVersion": 1,
"repository": "github.com:<upstream-owner>/<repository>"
}
Steps to reproduce
-
Clone a GitHub fork with one remote for the fork and a separate fetch-only remote for its parent. There is no
originremote. -
Set the fork as the push/default GitHub repository:
git config remote.pushDefault fork git config remote.fork.gh-resolved <fork-owner>/<repository> -
In the fork, create two open PRs intended to form a stack. Both PRs have base and head repositories equal to
<fork-owner>/<repository>. -
Run:
gh stack link --base main --remote fork --open <first-pr> <second-pr>
Actual behavior
The extension calls the parent repository's stack endpoint and fails:
Checking existing stacks...
failed to list stacks: HTTP 403
(https://api.github.com/repos/<upstream-owner>/<repository>/stacks?per_page=100&page=1)
The authentication failure is expected for that parent repository. The unexpected behavior is querying the parent at all.
Expected behavior
gh stack link --remote fork should query and mutate stack metadata in <fork-owner>/<repository>, matching:
- the explicitly selected remote;
remote.pushDefault;- standard
ghrepository resolution; and - the base/head repository of every PR passed to
--open.
If these signals disagree, the extension should fail before making an API request and report which repository needs to be selected.
Controls
The correct fork endpoint is accessible with the same authentication:
gh api 'repos/<fork-owner>/<repository>/stacks?per_page=100&page=1'
# HTTP 200
Running the same link command from a temporary Git repository whose only remote is <fork-owner>/<repository> succeeds:
Created stack with 2 PRs
This isolates the failure to repository resolution in the multi-remote fork clone rather than authentication, PR shape, or stack creation.
Impact
gh stack linkcannot be used normally in this fork/multi-remote layout.- Users may receive misleading authentication errors for a repository they did not select.
- Where the user has access to both repositories, the command may read or write stack metadata in the wrong repository.
Workaround
Run gh stack link from a temporary repository configured with only the fork remote. This is error-prone and loses the normal relationship with the working clone.
Related
- #381 reports the likely shared repository-resolution defect for
gh stack submit. - #461 reports stale fork/parent metadata affecting
gh stack submitafter a remote rename.
If maintainers consider link covered by #381, I am happy for this to be closed as a duplicate; the additional reproduction may still be useful for a regression test.
- Linguagem predominante
- Go
- Estrelas
- 1.5k
- Forks
- 73
- Merge médio
- 1d 8h
- PRs com merge (30d)
- 7
Guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de github/gh-stack
-
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 92/100
-
feature request topic: cli - general
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 68/100
-
feature request topic: auto-merge
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 68/100
-
bug topic: docs
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 68/100
-
feature request topic: cli - view
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
Todas as issues de github/gh-stack
Issues semelhantes
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 88/100
crossplane/crossplane#7859 ·
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 76/100
bazel-contrib/rules_go#4721 · 2 comentários ·
-
needs-triage
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 92/100
-
bug carvel-triage
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 88/100
carvel-dev/kapp-controller#1861 ·
-
area/logging kind/bug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 86/100