fix(vcs): resolve SSH aliases before classifying GitHub hosts - #7186
fix(vcs): resolve SSH aliases before classifying GitHub hosts#7186maslinedwin wants to merge 2 commits into
Conversation
Undotted remotes like git@github-personal:owner/repo were treated as GitHub Self-Hosted, so the pull-request pane invoked gh against a fake host. Detection now requires a real hostname before calling a remote self-hosted, and the server rewrites SSH aliases via ssh -G HostName for API/browser host while git auth still uses the alias.
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 11cbd8c. Configure here.
ApprovabilityVerdict: Needs human review This PR introduces new runtime behavior by spawning SSH processes to resolve aliases before provider detection. The cross-cutting changes to multiple services (identity resolution, PR listing, provider registry) and new external I/O operations warrant human review to verify the integration and error handling. You can customize Macroscope's approvability policy. Learn more. |
|
Note 🤖 GPT-6 Astra (preview) responding on behalf of Theo This note is part of an automated cleanup pass. Preserving these details from items reviewed in the cleanup pass. Carryover from #9497 at 1f21017: preserve Additional alias fixtures from #9487 at de7462b: Carryover from #6196 at 0fed43997d: cover GitManager's direct reads of the branch-selected remote, its |
Mnigos
left a comment
There was a problem hiding this comment.
Verified on the branch: the five touched test files pass, and swapping in main's sourceControl.ts makes the classifier and rewrite tests fail, so they pin the change. ssh -G on an alias that isn't in ssh config just echoes the name back, so the fallback never invents github.com.
One gap worth closing here, since #9497 was closed in favor of this PR: gitRemoteSshAliasToResolve skips any host containing a dot, so the documented multi-account form git@github.com-work:owner/repo.git (the case in #9458) never reaches ssh -G, and the new classifier still reports it as GitHub Self-Hosted with https://github.com-work as the base URL. On this branch detect returns {kind: github, name: GitHub Self-Hosted, baseUrl: https://github.com-work}, the canonical key stays github.com-work/owner/repo, and owner/repo parsing returns null. Dropping the dot gate and keeping only the public-host skip should be safe, since a dotted name that isn't an alias echoes back unchanged. Happy to send the carried-over test cases from #9497 as a follow-up if you'd rather keep this one focused.

Fixes #6198.
git@github-personal:owner/repono longer becomes GitHub Self-Hosted. SSH aliases are resolved viassh -Gto HostName for API/browser host; git auth still uses the alias.Note
Medium Risk
Touches provider detection, repository identity, and PR host routing with subprocess
ssh -Gcalls; failures are designed to fall back safely, but wrong resolution could mis-route API calls for affected remotes.Overview
Fixes misclassification of undotted SSH host aliases (e.g.
git@github-personal:…) as self-hosted GitHub/GitLab/Bitbucket. Provider detection now uses a resolveddetectionUrlwhile the stored git remote URL stays unchanged for clone/auth.SSH resolution: New
resolveGitRemoteForSourceControlrunsssh -Gonly for undotted, non-public aliases, rewrites the remote host viarewriteGitRemoteUrlHost, and falls back to the original URL on failure or timeout. Wired throughRepositoryIdentityResolver,SourceControlProviderRegistry, andPullRequestService(with async refinement and cached detection per remote).Classification:
detectSourceControlProviderFromRemoteUrltreats label matches likegithubingithub-personalas unknown unless the host is the public domain or contains a dot (real enterprise hostname).PR listing:
hostnameFromProviderBaseUrlusesURL.hostso self-hosted bases keep nonstandard ports (e.g.:8443).Docs note SSH-alias behavior;
@t3tools/sshgains optional timeout andfallbackOnErroronresolveSshTarget.Reviewed by Cursor Bugbot for commit 9c2eaa9. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Resolve SSH host aliases before classifying GitHub/GitLab/Bitbucket remotes
github-personal) were previously misclassified as self-hosted instances or unknown providers. The fix resolves the real hostname viassh -Gbefore provider detection and canonicalization.resolveGitRemoteForSourceControlwhich rewrites the SSH alias host usingrewriteGitRemoteUrlHostfrom shared; the original remote URL is kept for Git authentication.SourceControlProviderRegistry,RepositoryIdentityResolver, andPullRequestServiceall now resolve adetectionUrlbefore classifying or grouping remotes.hostnameFromProviderBaseUrlto preserve nonstandard ports in host values used for provider API selection and grouping.github-personal) are no longer treated as enterprise/self-hosted domains byisGitHubHost/isGitLabHost/isBitbucketHost.Macroscope summarized 9c2eaa9.