Skip to content

Add aliases kwarg to YAML.safe_load

Etienne Baqué requested to merge eb-add-aliases-kwarg into master

What does this MR do?

Related to gitlab-org/customers-gitlab-com#7467 (closed) Follow-up from !357 (merged)

When running the pipeline_ref_updater for CustomersDot, we end up with the following error:

/usr/local/lib/ruby/3.0.0/psych/visitors/to_ruby.rb:430:in `visit_Psych_Nodes_Alias': Unknown alias: secure-jobs-config (Psych::BadAlias)
...
from updater.rb:98:in `current_version'
from updater.rb:35:in `update'
from updater.rb:31:in `run'
from updater.rb:207:in `<main>'

This is because the kwarg aliases needs to be set to true upon running YAML.safe_load as the loaded YAML file, CustomersDot's .gitlab-ci.yml, has aliases.

From the safe_load docs:

A Psych::BadAlias exception will be raised if the yaml
contains aliases but the aliases parameter is set to false.

Manual testing

Run the following on master to replicate the error mentioned above

REF_UPDATE_GITLAB_API_TOKEN=<your_gitlab_token> ruby script/pipeline_ref_updater.rb "gitlab-org/customers-gitlab-com" .gitlab-ci.yml main

Run that same command on this branch to see the pipeline_ref_updater script run successfully.

Check-list

Edited by Etienne Baqué

Merge request reports