Skip to content

Fix Workhorse acceleration for encoded project IDs in API

Stan Hu requested to merge sh-fix-encoded-api-project-urls into master

All API endpoints support integer project IDs, but a number of others also support the URL-encoded form (e.g. group%2Fproject). For the sake of consistency, Workhorse should match on both integer and encoded formats. Endpoints that do not support the encoded form will return 400 whether they are accelerated by Workhorse or not.

I could be wrong about some of these, but when I started writing feature tests to cover this, I noticed NuGet returning 400 errors because the Grape API definitions were rejecting the :id. Here is the rundown:

Endpoint :id supports encoded format?
/api/v4/projects/:id/packages/nuget No
/api/v4/projects/:id/packages/maven Yes
/api/v4/projects/:id/packages/generic Yes
/api/v4/projects/:id/packages/conan No
/api/v4/projects/:id/packages/pypi No
/api/v4/projects/:id/packages/rubygems Yes
/api/v4/projects/:id/issues/[0-9]+/metric_images Yes
/api/v4/projects/:id/wikis/attachments Yes

Relates to https://gitlab.com/gitlab-org/gitlab/-/issues/324814

Edited by Stan Hu

Merge request reports