Skip to content
Source
Sign inSign up
pingdotgg/t3code

[Bug]: Remotes on ssh.bitbucket.org (forge SSH hosts) don't match their PRs' repository #22620

Closeditizarsa(GitHub profile, opens in a new tab) opened this issue 7 comments

Before submitting

  • I searched existing issues and did not find a duplicate.
  • I included enough detail to reproduce or investigate the problem.

Area

apps/server

Steps to reproduce

owner/repo is a placeholder.

  1. Clone a Bitbucket repo through Bitbucket's own SSH host: git@ssh.bitbucket.org:owner/repo.git (Bitbucket documents this host; it's also what HostName points to in many ~/.ssh/config setups).
  2. Register the checkout as a project. Its repositoryIdentity.canonicalKey becomes ssh.bitbucket.org/owner/repo (provider correctly detected as bitbucket).
  3. Ask T3 to write a review guide for a PR in bitbucket.org/owner/repo.

Expected behavior

The project is matched to the PR's repository and the guide is written.

Actual behavior

Guides are written from this project's checkout, and this pull request is in another repository. Write it from a project that is a checkout of that repository.

The canonical key keeps the SSH host (ssh.bitbucket.org), while the PR's repository is keyed by bitbucket.org, so the comparison fails. Changing the remote to git@bitbucket.org:owner/repo.git works around it.

The same likely applies to ssh.github.com (GitHub's SSH-over-443 host) and any other forge SSH hostname that differs from its web host.

Impact

Minor bug or occasional failure

Version or commit

T3 Code (Alpha) 0.1.1

Environment

macOS 26 (Darwin 25.6.0), desktop app

Workaround

Point the remote at the web host: git remote set-url origin git@bitbucket.org:owner/repo.git (SSH still works if ~/.ssh/config maps bitbucket.org to HostName ssh.bitbucket.org), then reload the project.

Suggested fix

Normalize known forge SSH hosts to their web host when building the canonical repository key (ssh.bitbucket.org → bitbucket.org, ssh.github.com → github.com), or compare by provider + owner + name instead of the raw host.

Related: #17805 (SSH host aliases classified as provider unknown) — different symptom, same root area (remote host → repository identity).


This issue was diagnosed and written by Claude Opus 5.5 (Claude Code, running in T3 Code).

  1. Note

    Grok responding on behalf of Julius.

    Thanks for the clear report. Current main matches it. The repository key is built from the remote's host and path as written (packages/shared/src/git.ts:144-174). The only forge whose SSH host gets mapped to the same key as its web host is Azure DevOps (lines 129-142). So git@ssh.bitbucket.org:owner/repo keys as ssh.bitbucket.org/owner/repo, while the pull request's repository keys as bitbucket.org/owner/repo, and the two never match. The same would apply to ssh.github.com, GitHub's SSH host on port 443.

    Switching the remote to git@bitbucket.org works, but ssh.bitbucket.org is a host Bitbucket documents itself, so it shouldn't need a workaround. This is separate from #17805, which is about custom SSH aliases from your own SSH config. These are fixed hosts the forges publish, so they can be recognized directly.

    Accepting this as a bug.

  2. juliusmarminge added labelsbug

  3. juliusmarminge added labelsaccepted

  4. juliusmarminge added labelsvia-triage

  5. @juliusmarminge is there something that's still required to get this moving?

  6. fwiw I get this on ssh.github.com, and the Create PR button in thread details fails because of it. The error hint was misleading too:

    Source control provider github failed in listChangeRequests: No GitHub credential for ssh.github.com: run `gh auth login --hostname ssh.github.com`.
  7. Additional symptom of the same root cause: sidebar PR clicks fall back to the external browser.

    Environment

    • T3 Code (Beta) 0.1.8, macOS 26
    • Remote: git@ssh.bitbucket.org:owner/repo.git (migrated from git@bitbucket.org:... following Atlassian's SSH hostname change; brownouts start Nov 12, 2026, so this remote form will become the norm for Bitbucket SSH users)
    • Bitbucket auth via Atlassian email + scoped API token works: API calls return 200 (/2.0/user, pullrequests/<n>, diffstat/statuses, etc.)

    Steps

    1. Register the checkout above as a project (repositoryIdentity.canonicalKey = ssh.bitbucket.org/owner/repo, provider correctly detected as bitbucket).
    2. Open a thread on a branch with a PR. The thread details sidebar shows the PR.
    3. Click the PR in the sidebar.

    Expected Internal PR view opens (pullRequestLinksOpenInApp = true, setting unchanged).

    Actual PR opens in the default browser instead. Desktop logs show ElectronShell.openExternal at click time.

    Analysis The internal viewer itself works — opening via + → Pull request in the workspace menu renders the PR internally. Only URL-based resolution from the sidebar row fails:

    • Project host derived from the canonical key is ssh.bitbucket.org.
    • PR web/API URL host is bitbucket.org.
    • isChangeRequestOnProjectHost requires strict equality (projectHost === link.host || projectHost === link.authority), so the sidebar click's reverse URL resolution returns no match and the click handler falls back to openExternal.
    • Before the SSH remote migration (git@bitbucket.org:...), the same click opened internally.

    Related observation: for this remote, recognizeRemote classifies the host as "Bitbucket Self-Hosted" (baseUrl: https://ssh.bitbucket.org), which also produced linked-PR records with host ssh.bitbucket.org / URLs like https://ssh.bitbucket.org/owner/repo/pull-requests/<n>.

    So beyond review guides (original report), this affects everyday PR navigation. The fix in #22625 (normalizing ssh.bitbucket.org → bitbucket.org in the repository key) likely addresses it once registered projects re-resolve their stored identity; noting the extra surface in case projectChangeRequestHost-based matching needs the same normalization.

  8. Local workaround: keep bitbucket.org in the Git remote URL and let SSH connect to ssh.bitbucket.org:

    # ~/.ssh/config
    Host bitbucket.org
        HostName ssh.bitbucket.org

    Preserve any existing port and identity settings. Then update the affected repository:

    git remote set-url origin git@bitbucket.org:OWNER/REPO.git
    git ls-remote origin HEAD

    Reload T3 Code to refresh its cached repository identity. These changes are local; nothing needs committing or pushing.

    Verified that Git access works with this configuration.

  9. Still reproduces on nightly 0.1.12-nightly.20261120.4994 (Windows 11, desktop app, Bitbucket Cloud). Same symptom: PR links in a thread open in the external browser instead of the in-app preview.

    • Remote git@ssh.bitbucket.org:owner/repo.git → project canonicalKey is ssh.bitbucket.org/owner/repo, provider bitbucket.
    • The link host is bitbucket.org, so projectChangeRequestHost (packages/source-control-core/src/shared/definition.ts:533) never equals it, and resolvePullRequestPreviewTarget returns null. This also blocks the same-host fallback (findProjectOnChangeRequestHost), so no Bitbucket project can serve the link.
    • packages/source-control-bitbucket/src/shared/definition.ts still defines no repositoryKeyFromRemote, even though line 127 notes that Cloud also clones from ssh.bitbucket.org and altssh.bitbucket.org. Same on main today.

    With Bitbucket moving SSH to ssh.bitbucket.org, this will hit every Bitbucket SSH user.

    Workaround confirmed on this build: Host bitbucket.org / HostName ssh.bitbucket.org in ~/.ssh/config, remote git@bitbucket.org:owner/repo.git, then re-add the project. sshResolvedRemoteUrl skips ssh -G for public forge hosts, so the key stays bitbucket.org/....

    Related: if the remote uses a custom SSH alias (Host work-bb → HostName ssh.bitbucket.org), the provider is also unknown (#17805). RepositoryIdentityResolver.ts:202 recognizes the provider from the raw remote, not from the ssh -G result used for the key.

    Triaged with Claude Opus 5.5 (Claude Code, t3 triage).

  10. Note

    Claude Opus 5.5 responding on behalf of shivam

    Closing as fixed by #42330 (merged in 01962d4c0b on Nov 24, after the last report above).

    The cause reported on Nov 20 was a project key of ssh.bitbucket.org/owner/repo against a PR link on bitbucket.org. On main, remotes on ssh.bitbucket.org and altssh.bitbucket.org are keyed under bitbucket.org, and keys already saved under those hosts compare equal. packages/source-control-bitbucket/src/shared/definition.test.ts covers both:

    • "names %s on bitbucket.org, where its pull requests live" covers SCP-style, ssh://…:443 and HTTPS remotes.
    • "matches pull requests for a key saved under %s" checks isChangeRequestInRepository and canReadChangeRequestOnHost.

    The sidebar and in-app PR links go through those same two checks (packages/client-runtime/src/changeRequestLinks.ts, apps/web/src/lib/openPullRequestLink.ts), so PR clicks should open in the app again.

    If it still happens on a build that includes #42330, reply here with your remote and the PR link and it will be reopened.

Sign in to join this conversation.