Commit b627a22a authored by Furkan Ayhan's avatar Furkan Ayhan

Merge branch 'aw-fix-type-error-from-tags-reference' into 'master'

Fix TypeError from Tags::Reference

See merge request gitlab-org/gitlab!80845
parents 124f7b9d 9a2ee677
......@@ -27,7 +27,7 @@ module Gitlab
override :_resolve
def _resolve(resolver)
object = resolver.config.dig(*location)
object = config_at_location(resolver)
value = resolver.deep_resolve(object)
raise MissingReferenceError, missing_ref_error_message unless value
......@@ -35,6 +35,12 @@ module Gitlab
value
end
def config_at_location(resolver)
resolver.config.dig(*location)
rescue TypeError
raise MissingReferenceError, missing_ref_error_message
end
def missing_ref_error_message
"#{data[:tag]} #{data[:seq].inspect} could not be found"
end
......
......@@ -69,6 +69,23 @@ RSpec.describe Gitlab::Ci::Config::Yaml::Tags::Reference do
end
end
context 'when the references are valid but do not match the config' do
let(:yaml) do
<<~YML
a: [1, 2]
b: [3, 4]
c: !reference [a, b]
YML
end
it 'raises a MissingReferenceError' do
expect { subject }.to raise_error(
Gitlab::Ci::Config::Yaml::Tags::Reference::MissingReferenceError,
'!reference ["a", "b"] could not be found'
)
end
end
context 'with arrays' do
let(:yaml) do
<<~YML
......
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