Fix TypeError from Tags::Reference
What does this MR do and why?
Gitlab::Ci::Config::Yaml::Tags::Reference
has been throwing a TypeError
when given specific combinations of references and configuration, such as the one below:
a: [1, 2]
c: !reference [a, b]
Because a
has no sub-key b
, Reference
was attempting [1, 2][:b]
, which resulted in a TypeError
because :b
cannot be cast to an integer.
This MR updates Reference
to catch the TypeError
and raise a MissingReferenceError
with an appropriate message that will help users fix their configuration.
Resolves: TypeErrorGraphqlController#execute
Part of: #349973 (closed)
Screenshots or screen recordings
The following examples use this CI configuration:
test_job:
script:
- echo "test"
- echo "done
tag_job:
script:
- !reference [test_job, script, sub_script]
Before fix:
Screen_Recording_2022-02-16_at_21.59.21
After fix:
Screen_Recording_2022-02-16_at_22.00.14
How to set up and validate locally
-
Go to
/-/graphql-explorer
-
Enter the following query:
query ($content:String!){ ciConfig(content: $content, projectPath: "flightJS/Flight") { errors stages { nodes { name } } } }
where
$content
is:test_job: script: - echo "test" - echo "done tag_job: script: - !reference [test_job, script, sub_script]
-
Enter the query, and see that you receive the error below
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.