Project

General

Profile

Actions

Bug #24640

closed

1.17 migration causes array/hash values for parameters to turn into strings with escaped quotes

Added by Tomer Brisker over 5 years ago. Updated over 5 years ago.


Description

Looks like an issue in db/migrate/20170112175131_migrate_template_to_parameters_macros.rb causes any such lookupkeys/lookupvalues to turn their values to strings.
Since the values are saved using update_attribute, callbacks aren't executed meaning cast_default_value is not called and the value remains a string.

For example:

#<VariableLookupKey:0x0000000015b50738
 id: 21532,
 key: "zdcaz",
 created_at: Thu, 16 Aug 2018 13:01:56 UTC +00:00,
 updated_at: Thu, 16 Aug 2018 13:01:56 UTC +00:00,
 puppetclass_id: 5,
 default_value: ["a", "b"],
 path: nil,
 description: "",
 validator_type: "",
 validator_rule: nil,
 key_type: "array",
 override: false,
 required: false,
 merge_overrides: false,
 avoid_duplicates: false,
 omit: nil,
 type: "VariableLookupKey",
 merge_default: false,
 hidden_value: false>
[152] pry(main)> k.default_value = convert(k.default_value.to_s)
=> "[\"a\", \"b\"]" 

As a workaround, it may be possible to iterate over all Lookupkeys and values and save them all again to ensure casting is called from foreman-rake console (please take care to backup your database before running this):

LookupKey.unscoped.find_each(&:save_without_auditing)


Files


Related issues 3 (0 open3 closed)

Related to Foreman - Feature #16740: Host parameters should be available in templates using some macroClosedOndřej Pražák09/29/2016Actions
Related to Foreman - Bug #23581: Upgrade to Foreman 1.17 converts YAML to JSON HashResolvedActions
Has duplicate Foreman - Bug #23809: Unable to save overridden Array class smart parametersDuplicateActions
Actions

Also available in: Atom PDF