API: Get raw file from repository does not work
Summary
The API method listed at https://docs.gitlab.com/ee/api/repository_files.html#get-raw-file-from-repository does not work. The almost identical route at https://docs.gitlab.com/ee/api/repository_files.html#get-file-from-repository does work.
Steps to reproduce
- Create a personal access token https://docs.gitlab.com/ee/api/#personal-access-tokens
- Create a project with a file
- Attempt to access the raw file using the method at https://docs.gitlab.com/ee/api/repository_files.html#get-raw-file-from-repository
What is the current bug behavior?
{"message":"404 File Not Found"}
What is the expected correct behavior?
The contents of the file should be returned
Relevant logs and/or screenshots
Working endpoint:
curl --request GET --header 'PRIVATE-TOKEN: <my-token>' 'https://gitlab.com/api/v4/projects/<project-id>/repository/files/README.md?ref=master'
{"file_name":"README.md","file_path":"README.md","size":38,"encoding":"base64","content":"SSdtIHRlc3RpbmcgYW4gaXNzdWUgd2l0aCBHaXRsYWIncyBBUEk=","ref":"master","blob_id":"2de1991e165807c9ee8ae5e3a326b6cd6f348439","commit_id":"754010889556fd66fd4c3b8ab82902791acae428","last_commit_id":"754010889556fd66fd4c3b8ab82902791acae428"
Broken endpoint trying to access same file
curl --request GET --header 'PRIVATE-TOKEN: <my-token>' 'https://gitlab.com/api/v4/projects/<project-id>/repository/files/README.md/raw?ref=master'
{"message":"404 File Not Found"}
Output of checks
This bug happens on GitLab.com. This bug also happens on self hosted versions of EE.
Possible fixes
I am guessing the file path resolution is what is breaking this endpoint, as the other mentioned endpoint uses this feature. Adding /raw
to the end of the path means that the route is indistinguishable from a file in a directory.