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: ...@@ -95,6 +95,9 @@ You can't use these keywords as job names:
- `variables` - `variables`
- `cache` - `cache`
- `include` - `include`
- `true`
- `false`
- `nil`
Job names must be 255 characters or less. [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/342800) 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`. in GitLab 14.5, [with a feature flag](../../administration/feature_flags.md) named `ci_validate_job_length`.
......
...@@ -15,7 +15,7 @@ module Gitlab ...@@ -15,7 +15,7 @@ module Gitlab
validate do validate do
each_unmatched_job do |name| 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 end
unless has_visible_job? unless has_visible_job?
......
...@@ -70,6 +70,14 @@ RSpec.describe Gitlab::Ci::Config::Entry::Jobs do ...@@ -70,6 +70,14 @@ RSpec.describe Gitlab::Ci::Config::Entry::Jobs do
it 'reports error' do it 'reports error' do
expect(entry.errors).to include 'jobs rspec config should implement a script: or a trigger: keyword' expect(entry.errors).to include 'jobs rspec config should implement a script: or a trigger: keyword'
end 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 end
context 'when no visible jobs present' do 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