Skip to content

[Bug]: GitLab repository lookup ignores the signed-in self-hosted host and queries gitlab.com when glab's default host is unset #26606

Open

Description

@janispritzkau

Before submitting

  • I searched existing issues and did not find a duplicate.
  • I included enough detail to reproduce or investigate the problem.

Area

apps/server

Steps to reproduce

  1. Sign glab in to a self-hosted GitLab only (e.g. glab auth login --hostname git.example.com). Leave glab's default host unchanged, so glab config get host still prints gitlab.com.
  2. In T3 Code, start a new project from a repository, choose GitLab and enter a bare project path that exists on the self-hosted instance, e.g. group/project.
  3. Submit the lookup.

Expected behavior

T3 Code finds the project on the self-hosted GitLab that glab is signed in to and shows its clone URLs, as it does when glab's default host is set to that instance.

Actual behavior

The lookup fails with:

Source control repository operation lookupRepository failed for gitlab: The source control operation could not be completed.

The server runs glab api projects/group%2Fproject from the user's home directory. That directory isn't a git repo, so glab has no remote to read a host from and falls back to its default host, gitlab.com. The project isn't there, so the call returns 404.

GitLabCli.getRepositoryCloneUrls builds the args as ["api", "projects/<encoded path>"] with no --hostname. Other GitLab calls already pass a host: readLinkSubject uses ["api", "--hostname", input.url.host, endpoint], and the auth probe uses glab auth status --hostname. The lookup should pass the host too, chosen in this order:

  1. the host in the URL, if the user entered a full URL (see [Bug]: New-project repository lookup fails for self-hosted GitLab when given a full URL — entire URL is sent as the project path to glab api projects/<encoded-url> #7849);
  2. otherwise the signed-in GitLab host from glab auth status, or a host picker if there are several.

The error message also misleads. glab's 404 is classified as not-found, and because GitLabCli.execute sets notFoundDetail: "Merge request not found.", the trace says "Merge request not found" for a repository lookup. The UI shows only the generic message (see #22342).

Impact

Blocks work completely

Version or commit

T3 Code (Beta) 0.1.3, stable channel (desktop)

Environment

macOS (Darwin 27.0), T3 Code desktop 0.1.3 (Electron 44.9.3), glab 1.124.0, self-hosted GitLab. glab auth status: signed in to the self-hosted host; gitlab.com has no token. glab config get host → gitlab.com.

Logs or stack traces

VcsProcessExitError: VCS process failed in GitLabCli.execute: glab (/Users/<user>) exited with 1 - Merge request not found.
    at GitLabCli.getRepositoryCloneUrls
    at GitLabSourceControlProvider.getRepositoryCloneUrls
    at SourceControlRepositoryService.lookupRepository
  -> GitLabCliCommandError: GitLab CLI failed in execute: GitLab CLI command failed.
  -> SourceControlProviderError: Source control provider gitlab failed in getRepositoryCloneUrls: GitLab CLI command failed.
  -> SourceControlRepositoryError: Source control repository operation lookupRepository failed for gitlab: The source control operation could not be completed.

# Same call, run by hand from ~:
$ glab api "projects/group%2Fproject"
ERROR  404 Not Found.

$ GITLAB_HOST=git.example.com glab api "projects/group%2Fproject"
{"id":178,"path_with_namespace":"group/project", ...}   # 200 OK

Workaround

Make the self-hosted instance glab's global default host:

glab config set --global host git.example.com

After that, the bare group/project lookup works. (Without --global, glab config set host fails outside a git repo with "not a Git repository".)

Related issues

Filed by

Claude Code (claude-opus-5-5)

Activity

  1. tiborrr commented on Nov 10, 2026

    @tiborrr

    Additional reproduction (self-hosted GitLab + WSL)

    Confirming the same failure on another machine.

    Environment

    • T3 Code t3 v0.1.8 (WSL2 / Ubuntu 24.04)
    • glab signed in only to self-hosted gitlab.easytrip-transport-services.com
    • glab config get host → gitlab.com
    • gitlab.com has no token (401 Unauthorized)

    UI
    Add project → Clone from GitLab → repository lookup toast:

    Repository lookup failed
    Source control repository operation lookupRepository failed for gitlab: The source control operation could not be completed.

    CLI check (matches this issue)

    $ glab config get host
    gitlab.com
    
    $ glab api "projects/t.casteleijn%2Ftest"
    {"message":"404 Project Not Found"}
    
    $ GITLAB_HOST=gitlab.easytrip-transport-services.com glab api "projects?membership=true&per_page=1"
    # succeeds against the self-hosted instance

    So lookup without --hostname / GITLAB_HOST still hits gitlab.com and fails, while the signed-in self-hosted host works when forced. Same root cause as described above.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions