GET /projects/:id/repository/files/:file_path doesn't return hidden files

I’m trying to retrieve some files from a repository via the Repository Files API (docs: Repository files API | GitLab) but any file in a hidden directory is returned as a 404, but hidden files in the root of the repo are successfully returned. Hidden in this case means the unix standard of a file or directory name beginning with a dot “.”.

For example, a file named .bar.txt in the root of the repo works:

/api/v4/projects/905/repository/files/.bar.txt?ref=master' → file is returned

However if a file is in a hidden directory, .foo/bar.txt the API returns a 404:

/api/v4/projects/905/repository/files/.foo/bar.txt?ref=master' → 404

In both cases the file is definitely there in the master branch. I’ve confirmed this with a git clone and a check via the Gitlab Web ui.

Is this intentional behaviour or is this something I can toggle in the Gitlab settings somewhere?

I can reproduce this, but I can’t see anything in the docs that explains it (but I may have missed something!).

I notice the same thing happens if you get the raw file from the repo.

I did find this issue which looks relevant or there might be others with the API label

@rk295 have you found a solution for this??