Skip to content

feat(scm): Pass GitLab repository paths to scm-platform - #128198

Merged
vaind merged 1 commit into
masterfrom
ivan/scm-gitlab-repository-path-c6b051
Oct 21, 2026
Merged

vaind merged 1 commit into
masterfrom
ivan/scm-gitlab-repository-path-c6b051

Conversation

@vaind

@vaind vaind commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

scm-platform's new git relay (getsentry/scm-platform#156) clones repositories, and for GitLab it builds the clone URL as <web_base_url>/<path>.git. Sentry doesn't give it a usable path today: for GitLab, the repository's name is the project's display name, such as GitLab.org / GitLab FOSS, not its path, gitlab-org/gitlab-foss. A clone URL built from the display name points nowhere, so the relay refuses GitLab repositories with missing_repository_path.

The real path is already stored in the repository's config (config["path"], written when the repository is linked). fetch_repository now copies it into the path key that scm-platform's Repository gained for this. GitLab repositories linked without a path in their config get path: None. Other providers get no path key, since their name already is the path.

The repository dict is built through cast(Repository, ...), so this works with Sentry's currently pinned sentry-scm, which doesn't declare path yet.

This is independent of #128164, which sets web_base_url for GitLab in the same function; the relay needs both before it can clone from GitLab.

Storing the path as the GitLab repository's name instead, which would make this key unnecessary, is tracked separately: related to SCM-293.

Sentry stores a GitLab project's display name ("Group / Project") as the
repository name, so scm-platform can't use it to address the project on
its host. Its git relay builds GitLab clone URLs from the repository's
path and refuses GitLab repositories without one, so take the real path
from the repository config.

Other providers already store the path as the name and get no `path` key.
@vaind
vaind requested a review from a team as a code owner October 20, 2026 15:06
@github-actions github-actions Bot added the Scope: Backend Automatically applied to PRs that change backend components label Oct 20, 2026
@linear-code

linear-code Bot commented Oct 20, 2026

Copy link
Copy Markdown

SCM-293

vaind added a commit to getsentry/scm-platform that referenced this pull request Oct 20, 2026
GitLabProvider built file, commit and merge request links from Sentry's
name for the repository with its spaces removed, but that name is
GitLab's display name ("GitLab.org / GitLab FOSS"), which differs from
the path (gitlab-org/gitlab-foss) in more than spaces. The links now use
Repository.path, which getsentry/sentry#128198 fills in, and refuse with
missing_repository_path without it. API calls address projects by id
and are unaffected.

Refs CW-2221

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@billyvg billyvg left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Would this be worth a migration later on, so that all repos have a canonical field for its path? This name vs path issue is/was a problem in Sentry in a bunch of places.

@vaind

vaind commented Oct 21, 2026

Copy link
Copy Markdown
Contributor Author

Would this be worth a migration later on, so that all repos have a canonical field for its path? This name vs path issue is/was a problem in Sentry in a bunch of places.

Already created an issue for this, linked above

@vaind
vaind merged commit 4020209 into master Oct 21, 2026
73 checks passed
@vaind
vaind deleted the ivan/scm-gitlab-repository-path-c6b051 branch October 21, 2026 08:52
vaind added a commit to getsentry/scm-platform that referenced this pull request Oct 22, 2026
GitLab web links are built from Sentry's repository name with its spaces
removed. That name is GitLab's display name ("GitLab.org / GitLab
FOSS"), not its path (`gitlab-org/gitlab-foss`), so most of the links
are wrong. The git endpoint for coding jobs
([CW-2221](https://linear.app/getsentry/issue/CW-2221/git-grants-and-relay-in-scm-platform))
needs the path for clone URLs too.

First of three stacked PRs, before #158 and
#156.

## Approach

- `Repository` gains an optional `path`, which Sentry fills for GitLab
from `repo.config["path"]`
([getsentry/sentry#128198](getsentry/sentry#128198)).
The RPC payload carries it, and a payload from an older server without
it reads as `None`.
- `GitLabProvider.web_repository_path` returns `path`, and raises
`missing_repository_path` without it. API calls use project ids and
don't change.

## Changes existing behaviour

Without a `path`, GitLab's link methods raise `missing_repository_path`
instead of returning a wrong link, so getsentry/sentry#128198 must be
deployed before Sentry or Seer takes a release with this.

## Tests

Links use the path and refuse without one; `path` round-trips through
the RPC payload and reads as `None` when absent.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Backend Automatically applied to PRs that change backend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants