GitLab should report YAML file is too big instead of invalid syntax message
Summary
If .gitlab-ci.yml
or it's includes don't fit into limits mentioned here #30098 (closed) GitLab wrongly reports 'invalid syntax' in various places.
In order for a user to figure out whats really wrong he has to use the CI Lint or Editor to see the real error.
Steps to reproduce
Create .gitlab-ci.yml
file big enough to exceed the limit.
What is the current bug behavior?
Open the file in GitLab UI in File browser (in case of include
):
What is the expected correct behavior?
Message in all pages correctly indicates The parsed YAML is too big
and point to a limit documentation.
This is how it looks in CI Lint:
Output of checks
This bug happens on GitLab.com
Proposal
- Update error messaging on pages that do not include the link to include
You can also validate your
.gitlab-ci.ymlfile with the pipeline editor.
- Pipeline Run page
- Pipeline Summary
- Open the file in GitLab UI in File browser (in case of
include
) - Pipeline list (on hover)
Techincal Proposal
- Currently
lib/gitlab/ci/config/external/file/base.rb
returns error messageIncluded file #{masked_location} does not have valid YAML syntax!
when the config coming from::Gitlab::Ci::Config::Yaml.load!
raises anyGitlab::Config::Loader::FormatError
(since DataTooLargeError inherits from FormatError and the we rescue any FormatError's
We could allow the more specific error message to bubble through.
something like:
diff --git a/lib/gitlab/ci/config/external/file/base.rb b/lib/gitlab/ci/config/external/file/base.rb
index 89da07969068..22154dbc75fc 100644
--- a/lib/gitlab/ci/config/external/file/base.rb
+++ b/lib/gitlab/ci/config/external/file/base.rb
@@ -84,6 +84,9 @@ def content_hash
strong_memoize(:content_yaml) do
::Gitlab::Ci::Config::Yaml.load!(content)
end
+ rescue Gitlab::Config::Loader::Yaml::DataTooLargeError
+ errors.push('new error here')
+ nil
rescue Gitlab::Config::Loader::FormatError
nil
end
Edited by Allison Browne