Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
Red Hat Satellite engineering is moving the tracking of its product development work on Satellite to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "Satellite project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs will be migrated starting at the end of May. If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "Satellite project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/SAT-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.

Bug 1618378

Summary: 1.17 migration causes array/hash values for parameters to turn into strings with escaped quotes
Product: Red Hat Satellite Reporter: Tomer Brisker <tbrisker>
Component: Smart VariablesAssignee: Tomer Brisker <tbrisker>
Status: CLOSED ERRATA QA Contact: Jitendra Yejare <jyejare>
Severity: high Docs Contact:
Priority: high    
Version: NightlyCC: bkearney, inecas, orabin, sghai, zhunting
Target Milestone: 6.4.0Keywords: Regression, Triaged, Upgrades
Target Release: Unused   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: foreman-1.18.0.10-1 Doc Type: Known Issue
Doc Text:
Users who have used complex values for parameters will get an error during upgrade of the beta. If this is encountered, please reach out to support for a fix.
Story Points: ---
Clone Of: Environment:
Last Closed: 2018-10-16 18:55:13 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Tomer Brisker 2018-08-16 14:00:35 UTC
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:
<pre>
#<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\"]"
</pre>

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):
<pre>
LookupKey.unscoped.find_each(&:save_without_auditing)
</pre>

Comment 1 Tomer Brisker 2018-08-16 14:00:41 UTC
Created from redmine issue http://projects.theforeman.org/issues/24640

Comment 2 Tomer Brisker 2018-08-16 14:00:46 UTC
Upstream bug assigned to tbrisker

Comment 5 Satellite Program 2018-08-20 16:06:08 UTC
Moving this bug to POST for triage into Satellite 6 since the upstream issue https://projects.theforeman.org/issues/24640 has been resolved.

Comment 8 Jitendra Yejare 2018-09-02 05:19:27 UTC
Verified!

@ Satellite 6.4 snap 19

Steps:

1. Created various and all types of class parameters before the upgrade.
2. Ran upgrade from 6.3.3-2 to 6.4.

Observation:

1. Upgrade completed successfully without any errors.
2. Also, the data and types of class parameters are intact after the upgrade.

Hence, changing the bug status to Verified.

Comment 9 Bryan Kearney 2018-10-16 18:55:13 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHSA-2018:2927