NuGet group endpoint rejects full group paths despite documented support

Summary

The group-level NuGet API rejects a full group path with {"error":"id is invalid"}, although the NuGet API documentation explicitly describes the id parameter as:

The group ID or full group path.

Using the numeric group ID works, but replacing it with the group's full path fails validation.

Steps to reproduce

  1. On a GitLab instance with the package registry enabled, use an existing top-level group, for example example-group.
  2. Request the NuGet service index using its numeric group ID:
    curl --url "https://gitlab.example.com/api/v4/groups/<numeric-group-id>/-/packages/nuget/index.json"
  3. Replace the numeric group ID with the group's full path:
    curl --url "https://gitlab.example.com/api/v4/groups/example-group/-/packages/nuget/index.json"
  4. Observe the validation error:
    {"error":"id is invalid"}

The example uses a top-level group without slashes in its path, so URL encoding of nested group paths is not involved.

Example Project

Reproduced on a self-managed GitLab instance. No public example project is currently available.

What is the current bug behavior?

The NuGet group endpoint accepts a numeric group ID but rejects a full group path during parameter validation.

This also prevents configuring a group-level NuGet source by path with dotnet nuget add source: subsequent requests to the source fail.

What is the expected correct behavior?

The endpoint should accept both a numeric group ID and a full group path, as documented.

Both forms should return a usable NuGet service index, and the resource URLs returned by that index should work with NuGet clients.

If group paths are intentionally unsupported, the documentation should be corrected instead.

Relevant logs and/or screenshots

$ curl --url "https://gitlab.example.com/api/v4/groups/example-group/-/packages/nuget/index.json"
{"error":"id is invalid"}

Output of checks

Observed on GitLab Self-Managed. Not verified on GitLab.com.

Results of GitLab environment info

GitLab server version: v19.5.6

Full environment information has not been collected.

Results of GitLab application Check

Not collected.

Possible fixes

The parameter validation in lib/api/nuget_group_packages.rb appears to explain the behavior:

params do
  requires :id, types: [Integer, String], desc: 'ID of the group.',
	regexp: ::API::Concerns::Packages::Nuget::PrivateEndpoints::POSITIVE_INTEGER_REGEX
end

Although the parameter accepts a string type, the positive-integer regular expression rejects group paths before group lookup can occur.

Consider allowing full group paths and reviewing downstream validation and generated resource URLs for compatibility. Regression tests should cover numeric IDs, top-level group paths, and URL-encoded nested group paths.

If this restriction is intentional, please update the documented parameter description to specify that only numeric group IDs are supported.

Edited by 🤖 GitLab Bot 🤖