API to "Get raw file from repository" fails for files with dots
Summary
Repository files with '.' in their name cannot be fetched in raw format from the v4 API. The request fails with 404 File Not Found
Steps to reproduce
$ curl -k --header "PRIVATE-TOKEN: <token>" "https://gitlab.com/api/v4/projects/gitlab-org%2Fgitlab-ce/repository/files/.gitignore/raw?ref=master"
or
curl -k --header "PRIVATE-TOKEN: <token>" "https://gitlab.com/api/v4/projects/gitlab-org%2Fgitlab-ce/repository/files/Gemfile.lock/raw?ref=master"
What is the current bug behavior?
{"message":"404 File Not Found"}
What is the expected correct behavior?
Raw file contents, i.e.:
*.swp
.DS_Store
.bundle
.chef
.directory
...
Notes and workaround
Asking for the file without the /raw
API tweak works, so the base64 contents can be decoded to fetch the file, e.g.:
curl -k --header "PRIVATE-TOKEN: <token>" "https://gitlab.com/api/v4/projects/gitlab-org%2Fgitlab-ce/repository/files/.gitignore?ref=master"
Files without '.' in their name can be fetched successfully using /raw
.
The bug was first discovered on gitlab-ee 9.1.