Skip to content

[Bug]: GitLab repository lookup fails for SSH clone URLs, scheme-less URLs and paths ending in .git #41871

Backlog

Description

@imrs776

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 (git.example.com, set as glab's default host).
  2. In T3 Code, start a new project from a repository, choose GitLab, and enter any of these forms for an existing project group/project:
    • [email protected]:group/project.git (the SSH clone URL GitLab shows in the Clone button)
    • git.example.com/group/project (URL without scheme)
    • group/project.git
  3. Submit the lookup.

Expected behavior

All three are normalized to host git.example.com (where present) and path group/project, the same as https://git.example.com/group/project(.git) already is since #7849.

Actual behavior

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

parseRepositoryLookup in packages/source-control-gitlab/src/server/GitLabCli.ts only splits the host and strips .git when the input matches ^https?://. Any other input is URL-encoded whole into glab api projects/<input>:

Input Call made Result
group/project projects/group%2Fproject ✅
https://host/group/project.git --hostname host projects/group%2Fproject ✅
host/group/project projects/host%2Fgroup%2Fproject ❌ 404
git@host:group/project.git projects/git%40host%3Agroup%2Fproject.git ❌ 404
group/project.git projects/group%2Fproject.git ❌ 404

Suggested fix: also accept scp-style user@host:path, ssh:// and scheme-less host/path (when the first segment matches a glab-authenticated host), and strip a trailing .git in the bare-path branch too.

Related: #26606 (no host chosen for bare paths), #40608 / #22342 (the 404 is reported as "Merge request not found." and hidden behind a generic toast).

Impact

Major degradation or frequent failure

Version or commit

T3 Code desktop 0.1.11 (stable)

Environment

Linux (AppImage), glab 1.131.0, self-managed GitLab

Logs or stack traces

VcsProcessExitError: VCS process failed in GitLabCli.execute: glab (/home/<user>) exited with 1 - Merge request not found.
SourceControlProviderError: Source control provider gitlab failed in getRepositoryCloneUrls: GitLab CLI command failed.

Workaround

Enter group/project or the full https:// URL.

Activity

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