Commit 42dd1dd2 authored by Furkan Ayhan's avatar Furkan Ayhan

Merge branch 'aw-fix-true-to-sym-error' into 'master'

Avoid exceptions from un-symbolizable jobs

See merge request gitlab-org/gitlab!80417
parents c5e1c3c8 f9b475c7
......@@ -95,6 +95,9 @@ You can't use these keywords as job names:
- `variables`
- `cache`
- `include`
- `true`
- `false`
- `nil`
Job names must be 255 characters or less. [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/342800)
in GitLab 14.5, [with a feature flag](../../administration/feature_flags.md) named `ci_validate_job_length`.
......
......@@ -15,7 +15,7 @@ module Gitlab
validate do
each_unmatched_job do |name|
errors.add(name, 'config should implement a script: or a trigger: keyword')
errors.add(name.to_s, 'config should implement a script: or a trigger: keyword')
end
unless has_visible_job?
......
......@@ -70,6 +70,14 @@ RSpec.describe Gitlab::Ci::Config::Entry::Jobs do
it 'reports error' do
expect(entry.errors).to include 'jobs rspec config should implement a script: or a trigger: keyword'
end
context 'when the job name cannot be cast directly to a symbol' do
let(:config) { { true => nil } }
it 'properly parses the job name without raising a NoMethodError' do
expect(entry.errors).to include 'jobs true config should implement a script: or a trigger: keyword'
end
end
end
context 'when no visible jobs present' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment