Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(source-control): forge SSH hosts key to their web host's repository #34937

Openjuliusmarmingewants to merge 2 commits intomain fromrefs/pull/34937/headopened View on GitHub

juliusmarmingecommented

Repository keys keep the remote's host unless that forge's definition rewrites it with repositoryKeyFromRemote, and only Azure DevOps did. The GitHub definition now rewrites keys on ssh.github.com/ (GitHub's SSH-over-443 host) to github.com/.... The Bitbucket definition rewrites keys on ssh.bitbucket.org/ and altssh.bitbucket.org/ (the port-443 host Bitbucket documents; the issue only names ssh.bitbucket.org) to bitbucket.org/.... Projects on those remotes now get the same key as their pull requests, so review guides, Create PR, PR lookup and opening a PR in the app match again. The GitHub API host comes from the remote URL separately (gitHubApiHostForRemote -> apiHostForSshAlias), so that function now maps ssh.github.com to github.com; before, listChangeRequests posted to https://ssh.github.com/api/graphql. No new regex: the rewrites use only startsWith, slice and exact equality, linear in key length on any input. Reproduced first: both repro-branch table rows failed (ssh.bitbucket.org/workspace/repo and ssh.github.com/t3tools/t3code). Fixes pingdotgg/t3code#22620.

Fixes pingdotgg/t3code#22620

Reproduction on main

Commit 4e0b52806b (origin/main). Created two sample git checkouts: one with origin git@ssh.bitbucket.org:owner/repo.git, one with origin ssh://git@ssh.github.com:443/pingdotgg/t3code.git. Started T3CODE_DEV_SEED=0 vp run dev (fresh database), registered both with t3 project add, paired the web client, and opened a new thread draft in each project. For the ssh.github.com project the server's branch PR lookup (GitManager.findLatestPrForHeadContext -> GitHubSourceControlProvider.listChangeRequests) posted to https://ssh.github.com/api/graphql and failed: 'Source control provider github failed in listChangeRequests: Could not reach GitHub at ssh.github.com.' (server.trace.ndjson span attribute github.host=ssh.github.com). The Bitbucket project made no API call because the VM has no Bitbucket credential, so its key mismatch was shown with a unit test: two rows added to the existing 'sourceControlClients repository keys' table fail on main: ssh://git@ssh.github.com:443/T3Tools/T3Code.git keys as ssh.github.com/t3tools/t3code (expected github.com/t3tools/t3code), and git@ssh.bitbucket.org:Workspace/Repo.git keys as ssh.bitbucket.org/workspace/repo (expected bitbucket.org/workspace/repo).

Evidence

Real web client, Chromium, 1280×800, light theme, fresh synthetic database per commit. Register a checkout with origin ssh://git@ssh.github.com:443/pingdotgg/t3code.git, open a new thread draft, and search for #34898 in the composer. The identical scenario fails on base and passes on head (scenarios:prove, exit 0).

BeforeAfter
Commit4e0b52806bfdbdec782c
ResultPull requests could not be readMatching pull request appears
CaptureBefore: SSH-host PR lookup errorAfter: SSH-host PR lookup succeeds
RecordingBefore recordingAfter recording

Scenario source

AI-assisted; verified with the tests and tools listed above.

Not shown:

  • Bitbucket live PR matching was not exercised because no Bitbucket credential was available.
  • Review guides, Create PR, sidebar PR opening, desktop, and mobile were not exercised; this proof covers GitHub SSH-host PR lookup in the web composer.

Tests

vp test run packages/client-runtime/src/sourceControlClients.test.ts -t 'repository keys' before the fix: 2 failed (the repro rows). After: vp test run packages/client-runtime/src/sourceControlClients.test.ts packages/source-control-github/src/server/gitHubRepositoryResolution.test.ts: 57 passed, including a new assertion that gitHubApiHostForRemote('ssh://git@ssh.github.com:443/acme/web.git') is github.com. vp run check:changed: format, lint, knip, graphql, typecheck (12 packages) and tests (5 files, 76 tests) all passed.

Not in this change

  • GitLab's port-443 SSH host altssh.gitlab.com has the same key mismatch (open PR #22625 also covers it); not in this issue, left unchanged.
  • Projects whose canonical key was already saved as ssh./... are not migrated; this change only fixes how keys are computed from the remote.

AI-assisted; verified with the tests and tools listed above.

    1. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted

    2. Approvability

      Verdict: Approved at fdbdec7

      Macroscope's review found this PR approvable — Normalizes GitHub and Bitbucket SSH service hosts to their web repository identities and routes GitHub API requests to github.com. The mappings are narrowly scoped to explicit forge hosts, with no product-default or permission changes.

      You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    3. Thread transfer impact

      ✅ Thread transfer remains within every enforced ceiling.

      ProviderMetricMain baselineThis PRImpactPR ceiling
      CodexTotal thread wire5.0 KiB5.0 KiB0 B (0.0%)6.8 KiB✅
      CodexThread snapshot wire3.8 KiB3.8 KiB0 B (0.0%)4.9 KiB✅
      CodexLive turn WebSocket wire1.2 KiB1.2 KiB0 B (0.0%)2.0 KiB✅
      CodexLive turn WebSocket decoded21.5 KiB21.5 KiB0 B (0.0%)24.4 KiB✅
      CodexLive turn messages110 (0.0%)8✅
      ClaudeTotal thread wire5.0 KiB5.0 KiB0 B (0.0%)6.8 KiB✅
      ClaudeThread snapshot wire3.8 KiB3.8 KiB0 B (0.0%)4.9 KiB✅
      ClaudeLive turn WebSocket wire1.2 KiB1.2 KiB0 B (0.0%)2.0 KiB✅
      ClaudeLive turn WebSocket decoded21.9 KiB21.9 KiB0 B (0.0%)24.4 KiB✅
      ClaudeLive turn messages110 (0.0%)8✅

      Baseline: 9bcca04 · PR result: fdbdec7 · Source CI: success

      Scenario and decoded snapshot size

      10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.

      • Codex decoded thread snapshot: 108.5 KiB
      • Claude decoded thread snapshot: 108.8 KiB

      Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed.

    4. coderabbitai[bot](GitHub profile, opens in a new tab)commented
      Explain Change →

      No actionable comments were generated in the recent review.

      Walkthrough

      The repository-key handlers normalize supported Bitbucket and GitHub SSH host aliases to their web hosts. GitHub API-host resolution also maps ssh.github.com to github.com.

      Changes: SSH host normalization

      Layer / File(s)Summary
      Repository-key normalization
      packages/source-control-bitbucket/src/shared/definition.ts, packages/source-control-github/src/shared/definition.ts, packages/client-runtime/src/sourceControlClients.test.ts
      The Bitbucket and GitHub handlers normalize supported SSH host keys to their web-host keys and return null for other keys. Client tests cover the Bitbucket and GitHub aliases.
      GitHub API-host resolution
      packages/source-control-github/src/server/gitHubRepositoryResolution.ts, packages/source-control-github/src/server/gitHubRepositoryResolution.test.ts
      GitHub API-host resolution maps ssh.github.com to github.com. A test covers an SSH URL using port 443.

      Estimated code review effort: 2 (Simple) | ~10 minutes

      Change: Bug fix · Severity of issue fixed: Low

      Possibly related PRs

      • pingdotgg/t3code#23909: Resolves GitHub SSH aliases to the github.com API host, including aliases not covered by this change.
      • pingdotgg/t3code#22625: Implements overlapping SSH repository-key and GitHub API-host mappings.

      Suggested reviewers: maria-rcks, t3dotgg, macroscopeapp

      Merge Risk: Minimal · up to fdbde

      Projects with GitHub or Bitbucket SSH-alias remotes will now match their pull requests. No remaining merge-blocking risk was found.

      Pre-merge checks: Passed 4

      Check nameStatusExplanation
      Title checkPassedThe title names the main change: SSH host keys for forges are mapped to the web host's repository key. It follows the conventional commit form and is specific. It is a fix, and the change matches it. …
      Linked Issues checkPassedIssue #22620 requires that projects on Bitbucket's ssh.bitbucket.org host get the same repository key as their PRs (bitbucket.org/owner/repo). The suggested fix also names ssh.github.com to github.com…
      Out of Scope Changes checkPassedAll changed files map to issue #22620. The Bitbucket change covers ssh.bitbucket.org and altssh.bitbucket.org. The issue names only ssh.bitbucket.org, but altssh.bitbucket.org is the same forge's docu…
      Description checkPassedThe description covers the Problem (repository keys for ssh.github.com and ssh.bitbucket.org remotes do not match PR keys, so PR lookup fails), the Change (GitHub and Bitbucket repositoryKeyFromRemote…
      Full details: Title check

      Explanation

      The title names the main change: SSH host keys for forges are mapped to the web host's repository key. It follows the conventional commit form and is specific. It is a fix, and the change matches it. The title is 71 characters, which is acceptable.

      Full details: Linked Issues check

      Explanation

      Issue #22620 requires that projects on Bitbucket's ssh.bitbucket.org host get the same repository key as their PRs (bitbucket.org/owner/repo). The suggested fix also names ssh.github.com to github.com. At the reviewed head: (1) packages/source-control-bitbucket/src/shared/definition.ts adds repositoryKeyFromRemote, mapping keys starting with ssh.bitbucket.org/ or altssh.bitbucket.org/ to bitbucket.org/<path>. (2) packages/source-control-github/src/shared/definition.ts adds repositoryKeyFromRemote, mapping keys starting with ssh.github.com/ to github.com/<path>. (3) packages/source-control-github/src/server/gitHubRepositoryResolution.ts apiHostForSshAlias maps ssh.github.com to github.com, so API calls do not go to the SSH host. The string handling uses startsWith, slice and indexOf, with no new regex. The PR adds test rows for both hosts in the sourceControlClients repository-keys table and an API-host assertion in gitHubRepositoryResolution.test.ts. I did not run the tests. Test results are taken from the PR description. The Evidence section is incomplete, but it is not a coding requirement. Both directly linked requirements are implemented in source.

      Full details: Out of Scope Changes check

      Explanation

      All changed files map to issue #22620. The Bitbucket change covers ssh.bitbucket.org and altssh.bitbucket.org. The issue names only ssh.bitbucket.org, but altssh.bitbucket.org is the same forge's documented SSH host, so it is closely related and not unrelated work. The GitHub key rewrite and the GitHub API-host mapping for ssh.github.com are named in the issue's suggested fix. The matching test changes support these behaviors. The PR does not change GitLab (altssh.gitlab.com) and does not migrate saved keys, both stated as non-goals. No unrelated change was found in the diffs reviewed.

      Full details: Description check

      Explanation

      The description covers the Problem (repository keys for ssh.github.com and ssh.bitbucket.org remotes do not match PR keys, so PR lookup fails), the Change (GitHub and Bitbucket repositoryKeyFromRemote rewrites and the GitHub API host mapping), Scope (links issue #22620 and states the bug), and Verification (reproduction on main, a before/after table with screenshots and recordings, unit test runs with results, and a list of what was not checked). It also states the AI assistance and the items left out of scope. The template's sections are all present and substantively filled. Minor gaps: the description does not name the model and harness used, which the template asks for when an agent was used, and the 'Fixes' line is duplicated. Neither gap is critical.

      Finishing Touches

      Generate unit tests (beta)

      • Commit to this branch
      • Create a new PR
      • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
      Recent review info

      Run configuration

      Commits

      Reviewing files that changed from the base of the PR and between 9bcca0443c1ebe4bfa73ba5e1e4eed58412e7859 and fdbdec782c94678ed950c693576f0ed029d27987.

      Files selected for processing: 5

      • packages/client-runtime/src/sourceControlClients.test.ts
      • packages/source-control-bitbucket/src/shared/definition.ts
      • packages/source-control-github/src/server/gitHubRepositoryResolution.test.ts
      • packages/source-control-github/src/server/gitHubRepositoryResolution.ts
      • packages/source-control-github/src/shared/definition.ts

      Limit details: You’ve used all 10 included reviews currently available.

    5. tanstack-source added labelsbug

Sign in to join this conversation.