• Stan Hu's avatar
    Fix Error 500 in parsing invalid CI needs and dependencies · 334e3c37
    Stan Hu authored
    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 https://gitlab.com/gitlab-org/gitlab/issues/195653
    334e3c37
job.rb 9.35 KB