Backend: CI merge request pipelines don't start if remote branch matches a protected branch pattern

Summary

When a merge request is created with a remote branch name that matches a pattern in the protected branches list, it does not start the pipelines and instead presents a perpetual rotating circle and Checking pipeline status. message.

Steps to reproduce

  1. Create a project and populate it with some content (or reuse an existing project).
  2. Set up a protected main branch for the project with only maintainers allowed to push but developers and maintainers allowed to merge.
  3. Set a protected wildcard branch for the project (it may work for exact match entries, but I didn't test that. We used rhel-* as our wildcard)
  4. Set Allowed to merge and Allowed to push both to No one. Set the force push and codeowner buttons to disabled.
  5. Create a fork of the project in another namespace.
  6. Commit a minor change and push it to a branch that matches the protected branch's wildcard (We used rhel-9-main)
  7. Create a merge request from the fork's rhel-9-main branch to the original project's

Example Project

Actual example: redhat/centos-stream/rpms/grub2!46 (closed)

Same patch was able to start the pipeline when submitted from a branch called randomname: redhat/centos-stream/rpms/grub2!50 (closed)

What is the current bug behavior?

The pipeline doesn't start when the merge request is created. Attempting to manually run it from the Pipelines tab results in an unhelpful error message: An error occurred while trying to run a new pipeline for this merge request. The "Learn more" button does not provide any information related to the specific failure.

What is the expected correct behavior?

The pipelines should start and run.

Relevant logs and/or screenshots

See real-world example project above.

Output of checks

This bug happens on GitLab.com