Skip to content

fix(validators): allow GitLab URLs with nested subgroups#1452

Open
truecallerabreham wants to merge 1 commit into
modelcontextprotocol:mainfrom
truecallerabreham:fix/gitlab-subgroup-url-validation
Open

fix(validators): allow GitLab URLs with nested subgroups#1452
truecallerabreham wants to merge 1 commit into
modelcontextprotocol:mainfrom
truecallerabreham:fix/gitlab-subgroup-url-validation

Conversation

@truecallerabreham

Copy link
Copy Markdown

Summary

The gitlabURLRegex in internal/validators/utils.go only allows two path segments (owner/repo), rejecting valid GitLab URLs with subgroups like:

https://gitlab.com/myorg/team/subgroup/my-mcp-server

GitLab subgroups are a standard feature used in GitLab Enterprise. The current regex prevents self-hosted registries from publishing servers whose source lives in a GitLab group hierarchy.

Changes

  • Updated gitlabURLRegex to allow any number of path segments: [\w.-]+(/[\w.-]+)*
  • Added unit tests for GitLab URLs with 1, 2, and 3 levels of subgroups
  • Added comprehensive test suite for IsValidRepositoryURL function

Test Plan

  • Added unit tests for subgroup URLs
  • Run go test ./internal/validators/... (requires Go installation)

Related

Fixes #1359

The gitlabURLRegex only allowed two path segments (owner/repo),
rejecting valid GitLab URLs with subgroups like:
https://gitlab.com/myorg/team/subgroup/my-mcp-server

This is a standard GitLab feature used in GitLab Enterprise.

Changes:
- Updated regex to allow any number of path segments
- Added unit tests for subgroup URLs (1, 2, and 3 levels deep)
- Added comprehensive test cases for IsValidRepositoryURL

Fixes modelcontextprotocol#1359
@nbeai

nbeai commented Jul 18, 2026

Copy link
Copy Markdown

Thanks for adding subgroup coverage. One thing I think may fail in the new table test: the updated GitLab regex now allows a single path segment (gitlab.com/owner), because (/[\w.-]+)* can repeat zero times. That seems to conflict with the new GitLab URL missing repo case expecting false.

Maybe the pattern should still require at least two path segments, then allow extra subgroup segments after that, e.g. .../[\w.-]+/[\w.-]+(/[\w.-]+)*/?$.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

GitLab repository URLs with nested groups/subgroups are rejected by validator

2 participants