`checkGitHubForPrBranch` associates branches with stale closed PRs via their tracked upstream (e.g. branches tracking `origin/dev`)
Mantenedores costumam responder em até 1 dia
Avaliação
Esta issue ainda não foi avaliada.
Descrição
Info:
- Extension version: 0.136.0
- VSCode Version: 1.116.0 (Universal)
- OS: macOS 26.3.1
- Repository Clone Configuration: single repository
- GitHub Product: GitHub.com
Summary
ReviewManager.checkGitHubForPrBranch looks up PRs by branch.upstream.name and writes the result to branch.<name>.github-pr-owner-number with no state === 'OPEN' guard. For any local branch that tracks a shared upstream like origin/dev, this resolves to whatever closed PR ever used head=dev on that repo, and the stale mapping persists permanently (because the write only fires when no metadata exists).
Symptoms: the GitHub Pull Requests panel logs This PR is no longer valid / Unable to resolve PR #..., the PR view won't open for the branch, and git config branch.<name>.github-pr-owner-number points to an unrelated closed PR.
Steps to Reproduce:
Prerequisite: a repository with at least one CLOSED PR whose headRefName is a commonly-tracked base branch name (dev, main, etc.). In my case the offending PR was closed without merge in October 2024.
- Create a new local branch tracking the base ref:
(Equivalent triggers:git checkout -b my-feature origin/devgit worktree add <dir> -b my-feature origin/dev, orgit branch --track my-feature origin/dev.) This setsbranch.my-feature.merge = refs/heads/devandbranch.my-feature.remote = origin. - Open the repo in VS Code with the GitHub Pull Requests extension enabled.
- Within a few seconds (on activation or the 5-min poll),
checkGitHubForPrBranchfires. - Inspect config:
git config --get branch.my-feature.github-pr-owner-number— it references an old closed PR whoseheadRefNamewasdev.
Subsequently, even after pushing my-feature with -u (which corrects branch.my-feature.merge to refs/heads/my-feature), the stale PR mapping persists because the write path is gated on "no metadata exists". The PR view remains broken until the config entry is manually unset.
Expected
No mapping should be written. A local branch tracking origin/dev has no PR reachable via its upstream's head ref name — the branch's own (future) remote ref would be my-feature, not dev.
Actual
Output log shows:
[Review+0] Found matching pull request metadata for current branch my-feature. Repo: owner/repo PR: <OLD_CLOSED_PR_NUMBER>
[Review+0] Resolving pull request
[Review+0] This PR is no longer valid
[Review+0] Unable to resolve PR #<OLD_CLOSED_PR_NUMBER>
The stale mapping also spreads to any branch created from origin/dev before being pushed with its own name. In my workspace 17 distinct branches ended up with this mapping over a few months of normal worktree-based development.
Root cause
All permalinks pinned to 6596ede (current main).
ReviewManager.checkGitHubForPrBranchcallsgetUpstreamUrlAndNameto extractupstreamBranchName.getUpstreamUrlAndNamereturnsbranch.upstream.namewhen upstream is populated, or falls back tobranch.<name>.mergeminus therefs/heads/prefix. For a branch trackingorigin/dev, both paths yieldupstreamBranchName = "dev".checkGitHubForPrBranchpasses that togetMatchingPullRequestMetadataFromGitHub, which dispatches todoGetMatchingPullRequestMetadataFromGitHub→GitHubRepository.getPullRequestForBranch("dev", headOwner).- The GraphQL query
PullRequestForHeadruns withheadRefName: "dev"— no state filter. - Client-side filter at
githubRepository.ts#L752:
If no matching open PR exists, returnsconst mostRecentOrOpenPr = prs.find(pr => pr.state.toLowerCase() === 'open') ?? prs[0];prs[0]— any closed PR that ever usedhead=devcan match. PullRequestGitHelper.associateBranchWithPullRequestwrites the stale mapping to git config.
The semantic mistake: upstreamBranchName is treated as "this branch's name on the remote", but for a branch tracking a base branch (a very common pattern — e.g. git worktree add -b X origin/dev), it's actually the base branch's name on the remote, not the feature branch's future name.
Proposed fix
Option 1: in checkGitHubForPrBranch (or inside getMatchingPullRequestMetadataFromGitHub), skip the GitHub lookup when upstreamBranchName !== branch.name. A branch whose upstream ref name differs from its local name is tracking a base branch, not its own remote counterpart, and has no PR discoverable via that name.
Option 2: add a state === 'OPEN' guard to getPullRequestForBranch's client-side filter. This prevents closed-PR pollution even if the "different name" check is missed. It won't help in the rare case that an open PR happens to exist on the shared upstream.
Either fix should also address the same pattern in FolderRepositoryManager.associateLocalBranchesWithPRsOnFirstActivation.
Related
- #6711 covers the "same branch name reused after a PR closes" variant of the stale-metadata family. This issue is a distinct, broader trigger — branches that track a base branch rather than reusing a head ref name.
- #6134 first flagged
github-pr-owner-numberconfig-level misbehavior.
- Linguagem predominante
- TypeScript
- Estrelas
- 2.6k
- Forks
- 805
- Merge médio
- 1d 16h
- PRs com merge (30d)
- 42
Preparar o ambiente
Este projeto não oferece contêiner de desenvolvimento, Dockerfile nem guia de contribuição, então a configuração fica por sua conta: comece pelo README e veja nosso guia da primeira contribuição para os passos gerais.
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 microsoft/vscode-pull-request-github
-
Issue 3 — DocumentationAberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 68/100
microsoft/vscode-pull-request-github#8792 ·
Mantenedores costumam responder em até 1 dia
-
Plugin no longer gives access to GitHub issues while using personal account.Talvez já em andamento @alexr00 assumiu hoje. Abertainfo-needed
microsoft/vscode-pull-request-github#9064 · 1 comentário · 1 responsável ·
Mantenedores costumam responder em até 1 dia
-
Dependabot PR description is blank in VS Code but renders correctly on GitHubTalvez já em andamento @alexr00 assumiu há 1 dia. Aberta
Dificuldade 3/5 1-2 dias Facilidade para iniciantes 50/100
microsoft/vscode-pull-request-github#9063 · 1 responsável ·
Mantenedores costumam responder em até 1 dia
-
Configurable issue completion triggerTalvez já em andamento @alexr00 assumiu há 1 dia. Aberta
microsoft/vscode-pull-request-github#9062 · 1 responsável ·
Mantenedores costumam responder em até 1 dia
-
Branch deletion modal (0.168.0): "Delete All" reads as deleting the repository, and single deletes need two tripsTalvez já em andamento @alexr00 assumiu há 1 dia. Aberta
microsoft/vscode-pull-request-github#9060 · 1 responsável ·
Mantenedores costumam responder em até 1 dia
Todas as issues de microsoft/vscode-pull-request-github
Issues semelhantes
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
stellar/stellar-dev-skill#151 ·
Mantenedores costumam responder em até 1 dia
-
Trial & Error: guided Blind offer squeezes on phones and sits under the touch toolbar on iPadAbertaarea:arcade game ready-for-agent
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 62/100
fderuiter/deruiter.dev#2281 · 1 comentário ·
Mantenedores costumam responder em até 1 dia
-
scope: data grid type: bug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
Mantenedores costumam responder em até 2 dias
-
fix(frontend): correct VITE_IS_DEVELPOMENT typo in shared/app.ts and align dev environment flagsAberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 75/100
vicharanashala/ajrasakha#1439 ·
Mantenedores costumam responder em até 1 dia
-
Add: TV5Monde AsieAbertaapproved check:passed streams:add
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 68/100
Mantenedores costumam responder em até 1 dia