Return an error for an invalid ref_name

What does this MR do and why?

Contributes to #385708 (closed)

Sentry error: https://new-sentry.gitlab.net/organizations/gitlab/issues/1039473/?project=3

Problem

Git ref cannot start with - or include a whitespace. Currently we return an ArgumentError from the Gitaly.

Solution

Handle the exception and return a bad request error.

References

Please include cross links to any resources that are relevant to this MR This will give reviewers and future readers helpful context to give an efficient review of the changes introduced.

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.

Screenshots or screen recordings

Screenshots are required for UI changes, and strongly recommended for all other merge requests.

Before After
Screenshot_2024-11-06_at_11.41.23 Screenshot_2024-11-06_at_11.41.00

How to set up and validate locally

  1. Visit http://gdk.test:3000/api/v4/projects/3/repository/commits?ref_name=wrong%20name
  2. You should get a 400 error page with an error message (instead of 500 error)
Edited by Vasilii Iakliushin

Merge request reports

Loading