Skip to content

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

Open
Mnigos wants to merge 1 commit into
pingdotgg:mainfrom
Mnigos:ssh-alias-remotes
Open

fix(shared): resolve multi-account SSH alias hosts to the real provider host#9497
Mnigos wants to merge 1 commit into
pingdotgg:mainfrom
Mnigos:ssh-alias-remotes

Conversation

@Mnigos

@Mnigos Mnigos commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

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 for commit 1f21017. Configure here.

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.

…er host

A remote like git@github.com-work:org/repo.git, the documented ~/.ssh/config
convention for multiple accounts, leaked the alias into every derived value:
the provider base URL became https://github.com-work, the normalized identity
key kept the alias so PR URLs never matched the project, and the owner/repo
parser returned null. SSH remotes now canonicalize an aliased github.com,
gitlab.com, or bitbucket.org host back to the real one; HTTPS remotes keep
their literal host. Also drops GitManager's private copy of the owner/repo
parser in favor of the shared one.

Fixes pingdotgg#9458
@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
@macroscopeapp

macroscopeapp Bot commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

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.

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

1 participant