Return 400 error when Branches API receives an invalid regex

What does this MR do and why?

Sentry error: https://new-sentry.gitlab.net/organizations/gitlab/issues/1805395

Problem

Regexp parser can raise 'RegexpError' exception that is currently unhandled. As a result, the user will see a 500 server error.

Solution

Capture 'RegexpError' exception and respond with 400 error with an message explaining what is wrong.

How to set up and validate locally

  1. Visit http://gdk.test:3000/api/v4/projects/1/repository/branches?regex=wrong(
  2. It should return an 400 error with an error message

Screenshot_2025-08-08_at_17.09.46

MR acceptance checklist

Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Vasilii Iakliushin

Merge request reports

Loading