Skip to content

fix(source-control): detect authenticated self-hosted gitlab remotes#2480

Open
GuilhermeVieiraDev wants to merge 1 commit intopingdotgg:mainfrom
GuilhermeVieiraDev:fix/gitlab-self-hosted-detection
Open

fix(source-control): detect authenticated self-hosted gitlab remotes#2480
GuilhermeVieiraDev wants to merge 1 commit intopingdotgg:mainfrom
GuilhermeVieiraDev:fix/gitlab-self-hosted-detection

Conversation

@GuilhermeVieiraDev
Copy link
Copy Markdown
Contributor

@GuilhermeVieiraDev GuilhermeVieiraDev commented May 3, 2026

What Changed

Fixed GitLab self-hosted detection for repos whose host does not include gitlab in the remote URL.

The provider registry now keeps the existing remote URL detection as the first path, but lets providers resolve an unknown remote when they have a stronger signal. GitLab uses glab auth status from the repo cwd and only claims the repo when the remote host exactly matches an authenticated GitLab host.

Also updated GitLab auth discovery so glab auth status can still report GitLab as authenticated when one configured host fails but another host is logged in.

Why

Self-hosted GitLab instances can live on arbitrary domains, so checking whether the remote host contains gitlab is not enough.

This showed up when glab auth status returned a mixed result: one GitLab host failed auth, while the repo's self-hosted instance was authenticated. The old discovery path treated the whole command as unauthenticated because the command exited non-zero, and the provider routing still saw the repo as unknown because the remote host did not look like GitLab.

The fix keeps the heuristic behavior unchanged for normal GitHub, GitLab, Azure DevOps, and Bitbucket hosts, and only adds the extra provider-specific check for unknown remotes.

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • I included before/after screenshots for any UI changes
  • I included a video for animation/interaction changes

Note

Medium Risk
Changes provider detection/routing to run additional CLI auth probes for unknown remotes and alters GitLab auth parsing, which could misclassify providers or add latency if parsing/execution differs from expectations.

Overview
Improves GitLab self-hosted detection by adding provider-specific refinement for unknown remotes: the registry now optionally reruns provider CLI auth checks and lets a provider claim the remote when its authenticated host matches the remote host (including non-standard ports).

Updates GitLab CLI auth parsing to treat glab auth status as authenticated when any listed host is logged in (even if another host fails and the command exits non-zero), backed by a new gitLabAuthStatus parser and expanded unit tests. Also preserves ports in remote URL detection by switching to URL.host for baseUrl while classifying providers using the portless hostname.

Reviewed by Cursor Bugbot for commit 1200763. Bugbot is set up for automated code reviews on this repo. Configure here.

Note

Fix detection of authenticated self-hosted GitLab remotes from CLI auth status

  • Adds parseGitLabAuthStatusHosts and findAuthenticatedGitLabHost in gitLabAuthStatus.ts to parse glab auth status output into per-host auth records, supporting ports and non-standard hostnames.
  • Reworks parseGitLabAuth to report authenticated status when any host in the CLI output is logged in, even if the command exits non-zero (common when gitlab.com is unauthenticated but a self-hosted instance is).
  • Adds refineUnknownRemoteProvider in SourceControlProviderDiscovery.ts and wires it into SourceControlProviderRegistry.ts so that unknown remotes are re-evaluated against CLI auth status and promoted to a concrete provider.
  • Fixes detectSourceControlProviderFromRemoteUrl in sourceControl.ts to preserve ports in baseUrl while still classifying provider kind by hostname alone.
  • Behavioral Change: parseRemoteHost now returns the host with port included for HTTPS URLs; callers that relied on hostname-only values may need review.

Macroscope summarized 1200763.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 3, 2026

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 59a971cf-35b7-4186-836c-3b549853fa39

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions Bot added size:L 100-499 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list. labels May 3, 2026
Copy link
Copy Markdown
Contributor

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 64c268f. Configure here.

Comment thread apps/server/src/sourceControl/GitLabSourceControlProvider.ts Outdated
@macroscopeapp
Copy link
Copy Markdown
Contributor

macroscopeapp Bot commented May 3, 2026

Approvability

Verdict: Needs human review

This PR introduces new capability to detect self-hosted GitLab remotes via authentication probing, changing the provider resolution flow. While well-tested, this is a meaningful feature addition that affects runtime behavior beyond a simple bug fix.

You can customize Macroscope's approvability policy. Learn more.

@GuilhermeVieiraDev GuilhermeVieiraDev force-pushed the fix/gitlab-self-hosted-detection branch from 64c268f to 0a0d025 Compare May 3, 2026 21:53
@GuilhermeVieiraDev GuilhermeVieiraDev force-pushed the fix/gitlab-self-hosted-detection branch from 0a0d025 to 1200763 Compare May 4, 2026 10:17
@vercel
Copy link
Copy Markdown

vercel Bot commented May 4, 2026

@GuilhermeVieiraDev is attempting to deploy a commit to the Ping Labs Team on Vercel.

A member of the Team first needs to authorize it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L 100-499 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.

1 participant