API request for project fails when using `NAMESPACE/PROJECT_NAME`

Summary

API request for a project fails with a 404 error when the request is made using NAMESPACE/PROJECT_NAME but it succeeds when using the project's ID.

Steps to reproduce

  • When querying the API by using the [instance]/api/v4/projects/namespace%2Frepository-syntax, the result is an 404 error page.
  • When using the unencoded version [instance]/api/v4/projects/namespace/repository, the result is always {"message":"404 Project Not Found"}.
  • Using the id of the project ([instance]/api/v4/projects/[id]) works just fine, so it's not a permissions problem.
  • Querying the project by using the search function works, but a) returns an array of all matches and b) often returns multiple matches

Example Project

Originally encountered on our local CE instance (v. 12.7.2), but also observable on gitlab.com:

What is the current bug behavior?

Getting a 404 or a JSON encoding 404.

What is the expected correct behavior?

Getting JSON containing the project description

Output of checks

This bug happens on GitLab.com

Related issues

I originally stumbled upon this when investigating a problem with the gitlab-vscode-extension and created the issue there (see https://gitlab.com/fatihacet/gitlab-vscode-extension/issues/143). However, it probably originates here and might have a common cause with #197342 (closed) , #195791 (closed) , #35259 (closed)