404 error in Repository files API when use URL-encoded project ID

Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.

I use hosted gitlab CE and the "Repository Files" endpoint: GET /projects/:id/repository/files/:file_path documented here: https://docs.gitlab.com/api/repository_files/

I have a private project inside nested group on 2nd nesting level, i.e. Group/subgroup/repo. By default I try to use URL-encoded repository ID (:id), but have the next issues:

  1. When I use any branch name for the "ref" parameter (ref=main), I have the error "404 Commit not found". The only option is to use ref=HEAD.
  2. When I request a file inside any folder, gitlab returns "404 File not found" error. But when I request file from the repository root, it is fetched successfully - with the same repository ID, i.e. I'm sure that repo ID was generated in a correct way.

When I changed project ID to numerical one, everything works OK. Logs below:

image

Edited by 🤖 GitLab Bot 🤖