Validate GitLab CI/CD configuration fails with error 500 and cryptic message

Summary

Validation of some GitLab CI/CD configurations can cause the API to return 500 errors. When visiting the validation page, the validation fails with:

Pipeline simulation completed with errors Simulated a git push event for a default branch. Rules, only, except, and needs job dependencies logic have been evaluated. Learn more

Steps to reproduce

  1. Go to https://gitlab.com/api/v4/projects/components%2ftoolkit/ci/lint
  2. Response is
{
message: "500 Internal Server Error"
}

Also:

  1. Go to the project CI/CD validation page: https://gitlab.com/components/toolkit/-/ci/editor?branch_name=main&tab=2
  2. Fails with:

Pipeline simulation completed with errors Simulated a git push event for a default branch. Rules, only, except, and needs job dependencies logic have been evaluated. Learn more You do not have sufficient permission to run a pipeline on 'main'. Please select a different branch or contact your administrator for assistance.

Example Project(s)

What is the current bug behavior?

500 error. This is new, as this API endpoint was fine last week (Monday March 25th 2024).

What is the expected correct behavior?

  1. More explicit error
  2. If nothing changed in the project (last commit was 2 months ago), no 500.

Relevant logs and/or screenshots

Screenshot_2024-04-01_at_10.43.08

Output of checks

This bug happens on GitLab.com

Results of GitLab environment info

Expand for output related to GitLab environment info
(For installations with omnibus-gitlab package run and paste the output of:
`sudo gitlab-rake gitlab:env:info`)

(For installations from source run and paste the output of:
`sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production`)

Results of GitLab application Check

Expand for output related to the GitLab application check

(For installations with omnibus-gitlab package run and paste the output of: sudo gitlab-rake gitlab:check SANITIZE=true)

(For installations from source run and paste the output of: sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production SANITIZE=true)

(we will only investigate if the tests are passing)

Possible fixes

Edited by Philippe Lafoucrière