Skip to content

Fix Error 500 in parsing invalid CI needs and dependencies

Stan Hu requested to merge sh-fix-ci-lint-error into master

Consider the following .gitlab-ci.yml:

stages:
    - test
    - build
    - deploy
    
test:
    stage: test
    script:
        - echo 1
build:
    stage: build
    script:
        - echo 1
        
deploy:
    stage: deploy
    needs: ["build"]
    dependencies: "test" # notice: no brackets
    script:
        - echo 1

If either needs or dependencies were not arrays of strings, the validation for missing needs would fail because it was trying to calculate dependencies - needs, which is invalid.

Even though dependencies and needs have separate validations that check their types, the validation chain isn't halted if an error is encountered. Thus, the validation for missing needs would still try to run.

We fix this by checking the normalized (aka composed) job values in the needs section.

Closes #195653 (closed)

Edited by Stan Hu

Merge request reports