Inconsistent syntax check when definining multiple includes allows committing/executing invalid YAML
Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.
Summary
"Sibling-keywords" of include:-sub-keywords are not verified consistently. While the Pipeline Editor shows a schema warning, the general syntax check claims that everything is fine, and a pipeline that silently ignores the invalid keys is executed.
My examples below are very on the nose – a more insidious way for this to manifest is that you can do a typo and use project:include:files: rather than project:include:file: (notice the extra s) and not notice because your incorrect version just gets silently ignored/not included rather than reporting your syntax error.
Steps to reproduce
- Create new project
- Add
test2.ymlandtest3.ymlwith a basic job in them:# replace X with 2 or 3 respectively jobX: script: echo X - Add the following
.gitlab-ci.yml:stages: - validate - test - build - deploy include: - component: $CI_SERVER_FQDN/components/opentofu/validate@2.6.1 foobarnonexistant: 123 - remote: 'https://gitlab.com/gl-demo-ultimate-mgrabowski/test/-/raw/main/test2.yml' # replace with your own project path integrity123: 'sha256-L3/GAoKaw0Arw6hDCKeKQlV1QPEgHYxGBHsH4zG1IY8=' - project: 'gl-demo-ultimate-mgrabowski/test' file: 'test2.yml' - project: 'gl-demo-ultimate-mgrabowski/test' files: 'test3.yml' foobarnonexistant: 123 - local: 'test3.yml' foobarnonexistant: 123 inputs213: website: "My website" - local: test3.yml foobarnonexistant: 123 rules123: - if: $INCLUDE_BUILDS == "true" - template: Bash.gitlab-ci.yml foobarnonexistant: 123 - Observe a pipeline being executed
- Go to Pipeline Editor
- Observe
Pipeline syntax is correct.message - Note multiple schema issues being shown by the linter
- Change any of the "top-level" include keywords (i.e. change
component,project,localortemplateby adding an extra character to the word) - Observe invalid syntax now being reported for these infractions
- Remove all includes but the
project:one withfiles: 'test3.yml' - Observe
This GitLab CI configuration is invalid: include:include config contains unknown keys: files, foobarnonexistant.now being reported
Example Project
https://gitlab.com/gl-demo-ultimate-mgrabowski/zd-633570
What is the current bug behavior?
Parts of the syntax in include: statements are not properly validated and allow executing pipelines with invalid syntax by silently ignoring incorrect includes.
What is the expected correct behavior?
Incorrect include statements are reported as invalid YAML syntax and prevent pipeline execution.
Relevant logs and/or screenshots
Output of checks
This bug happens on GitLab.com

