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 logic by adding provider-specific remote resolution (via glab auth status) and tweaking host parsing to include ports, which could misclassify remotes if parsing is wrong. Impact is limited to source-control provider selection and auth discovery.

Overview
Fixes routing for self-hosted GitLab remotes whose domain doesn’t contain gitlab by adding a provider-specific unknown-remote detection hook: the registry now allows providers to resolve unknown remotes, and GitLab claims a remote only when its host exactly matches an authenticated host reported by glab auth status.

Improves GitLab auth discovery to treat glab auth status as authenticated even when the command exits non-zero, by parsing per-host sections, and updates shared remote URL parsing to preserve ports while classifying providers by hostname. Adds focused tests covering mixed-auth outputs and non-standard port remotes.

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

Note

Fix detection of authenticated self-hosted GitLab remotes

  • Adds makeRemoteDetector to GitLabSourceControlProvider that runs glab auth status to identify authenticated self-hosted GitLab hosts when provider context is unknown.
  • Extends SourceControlProviderRegistry with a resolveUnknownProviderContext step that invokes provider-supplied remote detectors to refine unknown contexts at runtime.
  • Adds parseGitLabAuthStatusHosts to parse multi-host glab auth status output and identify which host has an authenticated account.
  • Updates parseRemoteHost to use URL.host instead of hostname so ports are preserved in baseUrl, with provider classification using the portless hostname.
  • Behavioral Change: parseGitLabAuth now returns authenticated status when any host is authenticated in the CLI output, even if the CLI exits non-zero.

Macroscope summarized 0a0d025.

@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: 0f61c3c1-50c2-4c25-ab0e-81e611b5a47b

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

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.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


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
@macroscopeapp
Copy link
Copy Markdown
Contributor

macroscopeapp Bot commented May 3, 2026

Approvability

Verdict: Needs human review

This PR introduces new runtime behavior by adding a GitLab remote detection mechanism that executes CLI commands (glab auth status) for unknown providers. While well-tested, the scope extends beyond a simple bug fix to a new capability affecting source control provider resolution.

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
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