Raw submodule displays as empty blob in web UI
Summary
The web UI displays raw blobs from a repo given a commit and path, but if you pass the path to a submodule, you get back an empty blob.
Steps to reproduce
click on (or curl) https://gitlab.com/abliss/bugdemo/raw/c65fb343/submodule
Example Project
https://gitlab.com/abliss/bugdemo
What is the current bug behavior?
An empty blob is returned. See e.g. these headers:
HTTP/1.1 200 OK
Content-Length: 0
Note that this provides no information, and worse, is indistinguishable from actually having an empty file at that path.
What is the expected correct behavior?
It's debatable what should be returned. In order of my personal preference, I would suggest:
- return a length-40 text/plain page with the sha of the submodule, i.e. the same output as
git rev-parse $COMMIT:$PATH_TO_SUBMODULE. In this case,0c0e98372b42d70ecb1a3e7e3b002d40763321ac. This is most likely to give the user the information they're looking for, but could conflict with a text file at that path. - Return a text/plain page with the output of
git ls-tree $COMMIT $PATH_TO_SUBMODULE, in this case160000 commit 0c0e98372b42d70ecb1a3e7e3b002d40763321ac submodule. This is perhaps a bit less likely to conflict with a file at that path, and is more self-evident as being a submodule. - Do one of the above, but set the Http Status to something like
214 Transformation Appliedand/or use an HTTP Header to distinguish between a raw blob and the submodule output. - Fail the request, perhaps with
415 Unsupported Media Typeor501 Not Implementedor something. - Fail the request with
404 Not found, which seems like an inappropriate status code, but at least would be consistent with what happens when you pass a path to a tree. E.g. https://gitlab.com/gitlab-org/gitlab-ce/raw/c134a72c/tmp
Output of checks
This bug happens on GitLab.com
Edited by 🤖 GitLab Bot 🤖