Viewing JSON blobs in the frontend is broken
Summary
Given an URL like https://dev.gitlab.org/cookbooks/chef-repo/blob/master/roles/dev-gitlab-org.json, we expect to get a HTML page that contains a viewer for the file roles/dev-gitlab-org.json
on the master branch of the cookbooks/chef-repo
repository. Instead, the browser shows us some very nice JSON
Steps to reproduce
Request looks like:
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Encoding: gzip, deflate, br
Accept-Language: en-US,en;q=0.5
Connection: keep-alive
Cookie: (redacted)
DNT: 1
Host: dev.gitlab.org
Referer: https://dev.gitlab.org/cookbooks/chef-repo/tree/master/roles
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Firefox/60.0
What is the current bug behavior?
Lovely JSON, response has Content-Type: application/json
What is the expected correct behavior?
We should get a HTML page, with Content-Type: text/html
Output of checks
This bug happens on (dev.)GitLab.com
Possible fixes
I expect this is related to the rails5 upgrade, which is present on dev, but not GitLab.com. Since the file extension is json
, I guess rails is intercepting that in a way it never used to.
I think we're in https://gitlab.com/gitlab-org/gitlab-ce/blob/master/app/controllers/projects/blob_controller.rb#L39 - perhaps the request is being interpreted as application/json
? We're clearly requesting text/html
in Accept
though.