Skip to content

Avoid exceptions from un-symbolizable jobs

Avielle Wolfe requested to merge aw-fix-true-to-sym-error into master

What does this MR do and why?

This MR adds logic to avoid exceptions being thrown when a job with a name that cannot be cast to a symbol is invalid because it is missing a script: or trigger: keyword.

For example, a job named true is valid if it is fully defined:

true:
  script: echo "true"

However, if it is not fully defined:

true:

It will cause the linting process to throw a NoMethodError because the YAML parser interprets the job name true into the Ruby boolean true, which throws NoMethodError when the error message code attempts to cast it to a symbol in order to add an error detailing that the job needs a script: or trigger: keyword.

Resolves: https://sentry.gitlab.net/gitlab/gitlabcom/issues/3152780/

Part of: #349973 (closed)

Screenshots or screen recordings

Before fix:

Screen_Recording_2022-02-10_at_19.02.22

After fix:

after fix

How to set up and validate locally

  1. Navigate to the CI configuration editor page
  2. Type a job named true: to the CI configuration. Do not add any keywords to the job
  3. See that you are properly given an error stating jobs true config should implement a script: or trigger: keyword

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Avielle Wolfe

Merge request reports