Return 404 error when `ref_type` + `ref` combination is incorrect
What does this MR do and why?
Contributes to #474461 (closed)
Problem
ref_type is used to strictly identify the reference type. For example,
when user has both tag and branch named test, then ref_type allow to
select the correct reference.
But there is no validation for correctness of ref + ref_type
combination on blob view page.
For example, user can request a missing tag
test with -/blob/test?ref_type=tags. The server returns 200
response with a broken page.
Another invalid combination is commit hash + ref_type:
-/blob/954620e6b3037e36b480bb6cd20caf110cc10c1b?ref_type=tags. Commit
hash doesn't support ref_type.
Solution
Return 404 error page in case when the invalid combination is requested.
MR acceptance checklist
Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
How to set up and validate locally
- http://gdk.test:3000/gitlab-org/gitlab-test/-/blob/master/CHANGELOG?ref_type=heads (expected 200)
- http://gdk.test:3000/gitlab-org/gitlab-test/-/blob/master/CHANGELOG?ref_type=tags (expected 404, before fix 200)
- http://gdk.test:3000/gitlab-org/gitlab-test/-/blob/missing/CHANGELOG (expected 404)
- http://gdk.test:3000/gitlab-org/gitlab-test/-/blob/ddd0f15ae83993f5cb66a927a28673882e99100b/CHANGELOG (expected 200)
- http://gdk.test:3000/gitlab-org/gitlab-test/-/blob/ddd0f15ae83993f5cb66a927a28673882e99100b/CHANGELOG?ref_type=heads (expected 404, before fix 200)