Skip to content

fix(shared): resolve SSH config host aliases in git remote URLs - #9487

Closed
ylcn91 wants to merge 2 commits into
pingdotgg:mainfrom
ylcn91:fix/ssh-alias-remote-host
Closed

fix(shared): resolve SSH config host aliases in git remote URLs#9487
ylcn91 wants to merge 2 commits into
pingdotgg:mainfrom
ylcn91:fix/ssh-alias-remote-host

Conversation

@ylcn91

@ylcn91 ylcn91 commented Sep 3, 2026

Copy link
Copy Markdown

What Changed

packages/shared/src/sourceControl.ts: parseRemoteHost strips an SSH config alias suffix from SSH hosts before provider detection, so git@github.com-work:org/repo.git now yields baseUrl: "https://github.com" instead of https://github.com-work. The rule lives in a new stripSshHostAlias helper.

packages/shared/src/git.ts: normalizeGitRemoteUrl canonicalizes the same way, so the repository identity key (and every host the app derives from it: the pull request host, the browser link, the list de-duplication key) reads github.com/org/repo. parseGitHubRepositoryNameWithOwnerFromRemoteUrl accepts the aliased host.

apps/server/src/git/GitManager.ts: the same one-token regex change on its local copy of that parser, so PR lookups resolve owner/repo for aliased remotes.

Focused tests for each: the alias forms, ports on ssh:// URLs, and the hosts that must stay as written (self-hosted and internal names, HTTPS remotes).

Why

Fixes #9458.

A Host github.com-work entry in ~/.ssh/config is the standard way to drive several GitHub accounts from one machine, and the remote then reads git@github.com-work:org/repo.git. T3 Code took that alias host literally: it became the identity's canonical key, the provider base URL, and the pull request URL, so reading a PR hit https://github.com-work/org/repo/pull/123 and failed on DNS.

The rule is deliberately narrow. Only SSH transports consult the SSH config, so HTTPS hosts are never touched. Only the hosted provider domains this module already special-cases (github.com, gitlab.com, bitbucket.org, ssh.dev.azure.com) followed by - are treated as an alias; a self-hosted or internal name such as github.example-corp is taken as written, since an internal zone may legitimately carry a hyphen there. Aliases that do not embed the real host at all (Host work) would need ssh -G resolution and are out of scope for this fix.

Existing projects pick up the corrected identity the next time it is resolved; nothing is migrated.

Model and harness: Claude Fable 5.1 in Claude Code.

Note

Fix parseGitHubRepositoryNameWithOwnerFromRemoteUrl to accept SSH config host aliases

Extends the GitHub SSH URL pattern in parseGitHubRepositoryNameWithOwnerFromRemoteUrl to match hostnames like github.com-work for both SCP-style and ssh:// remotes. This lets the parser extract owner/repo from remotes that use SSH config host aliases (e.g. git@github.com-work:owner/repo.git). HTTPS and git:// patterns are unchanged.

  • Risk: the broader SSH hostname pattern could match non-GitHub hosts that happen to use a github.com-* alias; verify no such remotes are expected in practice.

Macroscope summarized de7462b.

@github-actions github-actions Bot added vouch:unvouched PR author is not yet trusted in the VOUCHED list. size:M 30-99 changed lines (additions + deletions). labels Sep 3, 2026
Comment thread packages/shared/src/sourceControl.ts Outdated
@macroscopeapp

macroscopeapp Bot commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Approved at de7462b

Macroscope's review found this PR approvable — This focused bug fix corrects SSH host-alias handling across repository identity, provider detection, and pull-request lookup while preserving HTTPS and self-hosted behavior. The implementation is small, isolated, and covered by targeted regression tests.

You can add or adjust custom eligibility rules. Learn more.

@t3dotgg

t3dotgg commented Sep 4, 2026

Copy link
Copy Markdown
Member

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, where review continues on actual SSH HostName resolution. This suffix rule can rewrite a real hostname such as github.com-work.example and can copy an SSH port into the HTTPS API URL. The Azure and public-provider cases are recorded on the retained PR for follow-up.

@t3dotgg t3dotgg closed this Sep 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M 30-99 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Remote URL parser breaks for PRs when using a custom git SSH alias

2 participants