fix(source-control): handle self-hosted GitLab and multi-account GitHub auth#2480
fix(source-control): handle self-hosted GitLab and multi-account GitHub auth#2480GuilhermeVieiraDev wants to merge 5 commits intopingdotgg:mainfrom
Conversation
|
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 Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. 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 |
ApprovabilityVerdict: Needs human review Introduces new capabilities for multi-account GitHub authentication and self-hosted GitLab detection, including a new You can customize Macroscope's approvability policy. Learn more. |
64c268f to
0a0d025
Compare
0a0d025 to
1200763
Compare
|
@GuilhermeVieiraDev is attempting to deploy a commit to the Ping Labs Team on Vercel. A member of the Team first needs to authorize it. |
…d-detection # Conflicts: # apps/server/src/sourceControl/GitLabSourceControlProvider.test.ts # apps/server/src/sourceControl/SourceControlProviderRegistry.test.ts
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes 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 f5d8806. Configure here.

What Changed
Improved source-control auth discovery for mixed provider auth states.
For GitLab:
gitlab.unknownremote when they have a stronger auth signal.glab auth statusby host, so one failing configured GitLab host does not hide another authenticated host.glabhost.For GitHub:
gh auth status --json hostsinstead of parsing human-readable output.Why
Self-hosted GitLab instances can live on arbitrary domains, so checking whether a remote host contains
gitlabis not enough.The GitLab issue showed up when
glab auth statusreturned a mixed result: one configured host failed auth, while the repo's self-hosted instance was authenticated. The old path treated the whole command as unauthenticated because the command exited non-zero, and provider routing still saw the repo asunknownbecause the remote host did not look like GitLab.The GitHub issue is the same class of auth-discovery problem:
gh auth statuscan include multiple accounts forgithub.com, and one stale inactive account should not make GitHub look unauthenticated when another account is active and valid. GitHub exposes this state as structured JSON, so this now uses the CLI's JSON contract instead of human-readable terminal text.Bitbucket and Azure DevOps are left unchanged because their auth models are different: Bitbucket is API-token based in T3 Code, and Azure DevOps relies on Azure CLI login plus
az repos --detect.UI Changes
No UI changes. The settings screen now receives more accurate source-control auth state.
Checklist
Note
Medium Risk
Changes provider detection and CLI auth parsing for GitHub/GitLab, which can alter how repos are classified and whether integrations report authenticated (including reliance on
gh auth status --json). Failures could mis-route providers or misreport auth status in some environments.Overview
Improves source-control discovery to handle mixed auth states across multiple configured accounts/hosts, especially for self-hosted GitLab and multi-account GitHub.
GitHub auth probing now uses
gh auth status --json hostsand parses structured output to select the active authenticated account (or any authenticated account), while treating parsed-but-all-failed results as explicitly unauthenticated.GitLab auth probing now parses
glab auth statusby host so one failing host doesn’t hide another successful login, and provider detection can now refine an initiallyunknownremote into GitLab when the remote host exactly matches an authenticatedglabhost.Remote URL parsing now preserves ports in
baseUrl(URL.host), while still classifying providers using the hostname only; tests were updated/added to cover these scenarios.Reviewed by Cursor Bugbot for commit a066090. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Fix source control auth to support self-hosted GitLab and multi-account GitHub
gh auth status --json hosts, preferring active authenticated accounts and gracefully handling mixed account states.refineUnknownGitLabRemotewhich probesglab auth statusto upgrade an 'unknown' remote context to a concrete self-hosted GitLab provider, including remotes on non-standard ports.refineUnknownRemoteProviderin SourceControlProviderDiscovery.ts as a general mechanism for CLI-based refinement of unknown remotes, called during provider detection in SourceControlProviderRegistry.ts.parseRemoteHostso that HTTPS/HTTP remote URLs preserve the port inbaseUrl, while classification uses only the hostname.gh auth statusis now invoked with--json hostsinstead of plainauth status, which requiresghCLI v2.40+.Macroscope summarized a066090.