fix(shared): resolve multi-account SSH alias hosts to the real provider host - #9497
Open
Mnigos wants to merge 1 commit into
Open
fix(shared): resolve multi-account SSH alias hosts to the real provider host#9497Mnigos wants to merge 1 commit into
Mnigos wants to merge 1 commit into
Conversation
…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
Contributor
ApprovabilityVerdict: Approved at 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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A remote like
git@github.com-work:org/repo.git, the documented~/.ssh/configconvention for multiple GitHub accounts on one machine, leaks the alias into everything derived from the remote: the provider base URL becomeshttps://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 GitHubowner/repoparser returns null.SSH remotes now canonicalize an aliased
github.com,gitlab.com, orbitbucket.orghost back to the real one before deriving the base URL, the identity key, andowner/repo. HTTPS remotes keep their literal host, since only SSH goes through~/.ssh/configaliasing. 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/repoparsing when remotes use common~/.ssh/configSSH host aliases (e.g.git@github.com-work:org/repo.git).Shared layer: Adds
canonicalizeSshRemoteHostnameforgithub.com,gitlab.com, andbitbucket.orgalias suffixes, applied only for SSH remotes in provider detection and innormalizeGitRemoteUrl(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-hostedgithub.com-work).Server:
GitManagerdrops its duplicate GitHub parser and importsparseGitHubRepositoryNameWithOwnerFromRemoteUrlfrom 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
canonicalizeSshRemoteHostnamein sourceControl.ts to map recognized SSH aliases for GitHub, GitLab, and Bitbucket to their canonical public hostnames; other hostnames pass through unchanged.detectSourceControlProviderFromRemoteUrlandnormalizeGitRemoteUrlin git.ts to canonicalize the hostname only for SSH remotes, so HTTPS hosts that resemble aliases stay literal.parseGitHubRepositoryNameWithOwnerFromRemoteUrlto accept SSH host alias suffixes for both SCP-style and SSH-URL remotes; HTTPS and git-protocol forms still require the canonical GitHub host.canonicalizeSshRemoteHostnameonly 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.