Repository navigation
fix(gitlab): repository lookup uses the only signed-in glab host - #26646
juliusmarminge wants to merge 6 commits into
Conversation
…gned-in host These tests reproduce #26606: with no glab default host and a single signed-in self-hosted host, getRepositoryCloneUrls runs `glab api` without --hostname, so glab queries gitlab.com instead. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…glab host Outside a GitLab checkout glab falls back to gitlab.com, so a user signed in only to a self-hosted GitLab got a 404 when adding a GitLab repository or publishing to one. When `glab auth status` reports exactly one signed-in host, pass `--hostname <host>` to those `glab api` calls; otherwise, or if auth status cannot run, keep today's argv. Fixes #26606 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…a GITLAB_HOST --hostname rejects host:port and IP hosts and overrides a checkout's remote. Pass GITLAB_HOST in the child env instead, only when the user has not set GITLAB_HOST/GITLAB_URI/GL_HOST and no remote of the cwd is on gitlab.com or a host glab lists (glab would read its host from that remote, and GITLAB_HOST overrides it for `glab api`). Keep the host as `glab auth status` printed it, since glab matches config keys case-sensitively; existing comparisons lowercase at the call site. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The signed-in host fallback skipped remotes such as gitlab.com:team/app.git and set GITLAB_HOST over them. Share the provider's SCP-aware remote host parsing with the fallback guard. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… host glab also identifies a repository by a remote's push URL, and accepts userless SCP remotes with a trailing slash. Check both before pointing the fallback host at the only signed-in host. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ApprovabilityVerdict: Needs Human Approval Macroscope's review found this PR requires human approval — The fallback host for GitLab repository lookup and creation changes from gitlab.com to the sole signed-in host when no explicit host or recognized remote applies. Human review is needed to confirm this new default destination, including for project creation. You can add or adjust custom eligibility rules. Learn more. |
Thread transfer impact✅ Thread transfer remains within every enforced ceiling.
Baseline: Scenario and decoded snapshot size10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.
Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed. |
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Host parsing and casing packages/source-control-gitlab/src/server/GitLabCli.ts, packages/source-control-gitlab/src/server/GitLabSourceControlProvider.ts, packages/source-control-gitlab/src/server/gitLabAuthStatus.ts |
GitLab remote parsing handles userless SCP-style URLs. Authenticated host comparisons ignore casing, while parsed host entries retain their casing. |
Signed-in host selection packages/source-control-gitlab/src/server/GitLabCli.ts, packages/source-control-gitlab/src/server/GitLabCli.test.ts |
When no host variable is set, the CLI checks authentication status and Git remotes before selecting a host. Tests cover timeouts, remote configurations, and host-selection behavior. |
Repository API host integration packages/source-control-gitlab/src/server/GitLabCli.ts, packages/source-control-gitlab/src/server/GitLabCli.test.ts |
Repository lookup, namespace lookup, and project creation use the selected environment. Tests verify lookup and publishing with a sole signed-in host. |
Priority:
Estimated code review effort: 3 (Moderate) | ~20 minutes
Change: Bug fix · Severity of issue fixed: Medium
Sequence Diagram(s)
sequenceDiagram
participant GitLabCli
participant glab
participant GitService
participant ProcessExecution
GitLabCli->>glab: Check auth status with a 5-second timeout
glab-->>GitLabCli: Return configured hosts and accounts
GitLabCli->>GitService: Inspect remote fetch and push URLs
GitService-->>GitLabCli: Return remote URLs
GitLabCli->>ProcessExecution: Run repository API command with selected environment
Possibly related issues
- pingdotgg/t3code#17209 — The new 5-second timeout bounds the auth-status probe, but the change does not add caching for repeated probes.
- pingdotgg/t3code#22342 — The existing generic CLI error mapping remains; this change does not add diagnostic details.
Suggested labels: bugfix, size:L
Suggested reviewers: macroscopeapp, maria-rcks
Merge Risk: 
Minimal · up to 92014
-
The host-selection change appears mergeable after normal checks; no unresolved issue was established that would block repository lookup or publishing.
Pre-merge checks: 
4
-
Full details: Linked Issues check
-
Explanation
Issue
#26606requires bare GitLab repository lookup on the only signed-in self-hosted host.GitLabCliprobesglab auth status, requires one authenticated host, skips override when an explicit host or matching remote exists, and passes the printed host throughGITLAB_HOST. The lookup and repository creation calls use the selected environment. Tests cover the host, environment, remote, timeout, and publishing cases.
Full details: Out of Scope Changes check
-
Explanation
The changes stay within the GitLab host-selection fix for issue
#26606. Remote parsing, auth-host casing, provider comparisons, repository creation, and tests support safe host selection. The PR does not implement the excluded full-URL input, multi-host picker, or generic error-text changes.
-
Finishing Touches
-
📝 Generate docstrings
-
- Commit to this branch
- Create a new PR
🧪 Generate unit tests (beta)
-
- Commit to this branch
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Comment @coderabbitai help to get the list of available commands.
Problem
When glab is signed in only to a self-hosted GitLab and its default host is left at
gitlab.com, Add project → GitLab repository →group/projectfails with "Repository lookup failed". The lookup runsglab api projects/<path>from the server's working directory, which has no GitLab remote, so glab sends it to gitlab.com. Publishing a repository to GitLab has the same problem. Reproduced on main 886d8f6 against a stub self-hosted GitLab (see Verification).Change
Before a repository lookup or publish,
GitLabClirunsglab auth status(5 s timeout). It points glab at a host only when all of these hold:GITLAB_HOST,GL_HOSTorGITLAB_URI.In that case the glab child process gets
GITLAB_HOST=<that host>. In every other case, including a failed or timed-out probe, the command runs exactly as on main.GITLAB_HOSTand not--hostname: glab 1.124 rejects a host with a port as--hostname, but accepts it inGITLAB_HOST.glab auth statusprinted it, because glab matches its config keys case-sensitively.parseGitLabAuthStatusHostsno longer lowercases; its two existing callers lowercase where they compare.Out of scope:
Scope and approval
Fixes #26606
Triaged via the automated issue flow.
Verification
packages/source-control-gitlab/src/server/GitLabCli.test.ts:vp test run src/server/gives 126 passed (9 files).expected 'api projects/team%2Fapp' to contain '--hostname …'(later rewritten to assert the env), and passes with the fix.GITLAB_HOST; several signed-in hosts; a gitlab.com remote in the four forms (with a user, userless SCP, trailing slash, push URL only); publish passing the host on both API calls; and an auth-status timeout falling back to the original command.vp run check:changedpassed: format, lint, knip, typecheck, and tests next to the changes.glab config get hostprintsgitlab.comand onlygitlab.selfhosted.testis signed in, as in the report.glab api projects/team%2Fappgets a 404 from gitlab.com.GITLAB_HOSTset, the same call reaches the self-hosted host.team/app. The server-only change shows up as the lookup result.host: gitlab.com)Model and harness: Claude Opus 5.5 (Claude Code, T3 Code issue lead) with reviewers GPT-6.1 Sol (Codex) and Claude Opus 5.5.
🤖 Generated with Claude Code