Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(shared): resolve multi-account SSH alias hosts to the real provider host #9497

ClosedMnigos(GitHub profile, opens in a new tab)wants to merge 1 commit intomain fromrefs/pull/9497/headopened View on GitHub

A remote like git@github.com-work:org/repo.git, the documented ~/.ssh/config convention for multiple GitHub accounts on one machine, leaks the alias into everything derived from the remote: the provider base URL becomes https://github.com-work (the invalid domain from the issue), the normalized identity key keeps the alias so PR URLs never match the project, and the GitHub owner/repo parser returns null.

SSH remotes now canonicalize an aliased github.com, gitlab.com, or bitbucket.org host back to the real one before deriving the base URL, the identity key, and owner/repo. HTTPS remotes keep their literal host, since only SSH goes through ~/.ssh/config aliasing. GitManager's private copy of the owner/repo parser was byte-identical to the shared one, so it now imports it instead.

Covered by tests for all three derivations; each fails without the fix.

Fixes #9458.

Implemented with Claude Code (Claude Fable 5).


Note

Low Risk Narrow URL-parsing fix with tests; affects remote identity and PR association for SSH aliases but does not change auth or git execution.

Overview Fixes broken provider detection, normalized remote identity keys, and GitHub owner/repo parsing when remotes use common ~/.ssh/config SSH host aliases (e.g. git@github.com-work:org/repo.git).

Shared layer: Adds canonicalizeSshRemoteHostname for github.com, gitlab.com, and bitbucket.org alias suffixes, applied only for SSH remotes in provider detection and in normalizeGitRemoteUrl (URL and SCP forms). Extends the GitHub owner/repo parser regex for aliased SSH hosts. HTTPS remotes still use the literal hostname (e.g. self-hosted github.com-work).

Server: GitManager drops its duplicate GitHub parser and imports parseGitHubRepositoryNameWithOwnerFromRemoteUrl from shared so behavior stays in sync.

New unit tests cover alias canonicalization, non-SSH hosts left unchanged, and parsing through aliases.

Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 1f21017c647992af7829f0de04731211f17be569. Configure [here](https://www.cursor.com/dashboard/bugbot).

Note

Resolve multi-account SSH alias hosts to canonical provider host in shared git utils

  • Adds canonicalizeSshRemoteHostname in sourceControl.ts to map recognized SSH aliases for GitHub, GitLab, and Bitbucket to their canonical public hostnames; other hostnames pass through unchanged.
  • Updates detectSourceControlProviderFromRemoteUrl and normalizeGitRemoteUrl in git.ts to canonicalize the hostname only for SSH remotes, so HTTPS hosts that resemble aliases stay literal.
  • Expands parseGitHubRepositoryNameWithOwnerFromRemoteUrl to accept SSH host alias suffixes for both SCP-style and SSH-URL remotes; HTTPS and git-protocol forms still require the canonical GitHub host.
  • Replaces the local GitHub remote parser in GitManager.ts with the shared shared git utility.
  • Risk: canonicalizeSshRemoteHostname only recognizes a fixed set of alias hosts; SSH remotes using custom or future alias schemes will not be canonicalized and may be misclassified as self-hosted.
Macroscope summarized 1f21017.
    1. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched

    2. Approvability

      Verdict: Approved at 1f21017

      Macroscope's review found this PR approvable — This is a focused SSH remote-parsing bug fix with tests, changing only derived provider and repository identity data for recognized aliases while preserving existing HTTPS and unrelated-host behavior. No schema, authentication, deployment, product-default, or static-analysis configuration changes are involved.

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

      🤖 GPT-6 Astra (preview) responding on behalf of Theo

      This was closed as part of an automated cleanup pass. If you believe it was closed in error, reply here and we will get it reopened.

      Closing this alternative in favor of #7186, which resolves HostName from SSH configuration instead of guessing it from an alias suffix. Review continues there. The dotted-alias cases and GitManager checks are recorded there for follow-up, so this does not mark #9458 fixed.

Sign in to join this conversation.