From 485e72cb27d0ac6ffc2e1f79dc7f594d320e3eae Mon Sep 17 00:00:00 2001 From: Adam Grare Date: Thu, 1 Feb 2024 15:06:36 -0500 Subject: [PATCH] Fix YAML.load_file failing on aliases Fix configuring an internal database with ruby 3.1 failing due to aliases in the `config/database.pg.yml` file ``` /opt/manageiq/manageiq-gemset/gems/psych-4.0.6/lib/psych/visitors/to_ruby.rb:432:in 'visit_Psych_Nodes_Alias': Unknown alias: base (Psych::BadAlias) ``` --- lib/manageiq/appliance_console/database_configuration.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/manageiq/appliance_console/database_configuration.rb b/lib/manageiq/appliance_console/database_configuration.rb index 7a88a387..203e59c6 100644 --- a/lib/manageiq/appliance_console/database_configuration.rb +++ b/lib/manageiq/appliance_console/database_configuration.rb @@ -257,7 +257,13 @@ def self.load_current require 'fileutils' FileUtils.cp(DB_YML_TMPL, DB_YML) if File.exist?(DB_YML_TMPL) end - YAML.load_file(DB_YML) + + data = File.read(DB_YML) + if YAML.respond_to?(:safe_load) + YAML.safe_load(data, :aliases => true) + else + YAML.load(data) # rubocop:disable Security/YAMLLoad + end end def validate_encryption_key!