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 1565117

Summary: ISE on importing host subscriptions from a CSV - ActiveRecord::AssociationTypeMismatch: Katello::InstalledProduct expected, got ActiveSupport::HashWithIndifferentAccess
Product: Red Hat Satellite Reporter: Roman Plevka <rplevka>
Component: Subscription ManagementAssignee: Justin Sherrill <jsherril>
Status: CLOSED ERRATA QA Contact: Katello QA List <katello-qa-list>
Severity: high Docs Contact:
Priority: unspecified    
Version: 6.3.1CC: egolov, ehelms, jsherril, sghai
Target Milestone: UnspecifiedKeywords: Regression, Triaged
Target Release: Unused   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: tfm-rubygem-katello-3.4.5.64-1 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2018-04-13 13:32:28 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Roman Plevka 2018-04-09 12:41:08 UTC
Description of problem:
looks like 6.3.1-2 introduced this since the test was passing in snap#1.
thus i think it got introduced by
https://bugzilla.redhat.com/show_bug.cgi?id=1563262

importing a host subscription csv causes a ISE:

hammer -v -u admin -p changeme  csv content-hosts --organization="ao936E" --file="/tmp/chs_import_ao936E.csv"

[ERROR 2018-04-09 08:30:31 API] 500 Internal Server Error
[ERROR 2018-04-09 08:30:31 Exception] Error: 500 Internal Server Error
ejrqrvfjymialarl.lab.eng.rdu2.redhat.com,ao936E,m4ZJ91,TkreoTZuhu,,Yes,,Red Hat Enterprise Linux Server,x86_64,1,500208,1,,69|Red Hat Enterprise Linux Server,"""1|SER0232US|Red Hat Satellite Employee Subscription|10843764|477931"""

Error: 500 Internal Server Error
ejrqrvfjymialarl.lab.eng.rdu2.redhat.com,ao936E,m4ZJ91,TkreoTZuhu,,Yes,,Red Hat Enterprise Linux Server,x86_64,1,500208,1,,69|Red Hat Enterprise Linux Server,"""1|SER0232US|Red Hat Satellite Employee Subscription|10843764|477931"""
[ERROR 2018-04-09 08:30:31 Exception] 

RuntimeError (500 Internal Server Error
ejrqrvfjymialarl.lab.eng.rdu2.redhat.com,ao936E,m4ZJ91,TkreoTZuhu,,Yes,,Red Hat Enterprise Linux Server,x86_64,1,500208,1,,69|Red Hat Enterprise Linux Server,"""1|SER0232US|Red Hat Satellite Employee Subscription|10843764|477931"""
):
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli_csv-2.3.0/lib/hammer_cli_csv/base.rb:153:in `rescue in block (3 levels) in thread_import'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli_csv-2.3.0/lib/hammer_cli_csv/base.rb:148:in `block (3 levels) in thread_import'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli_csv-2.3.0/lib/hammer_cli_csv/base.rb:146:in `each'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli_csv-2.3.0/lib/hammer_cli_csv/base.rb:146:in `block (2 levels) in thread_import'
    /opt/theforeman/tfm/root/usr/share/gems/gems/logging-1.8.2/lib/logging/diagnostic_context.rb:323:in `block in create_with_logging_context'


The production log reveals the error:


2018-04-09 08:30:31 7ef7af6c [app] [I] Started PUT "/api/hosts/7" for 10.16.184.122 at 2018-04-09 08:30:31 -0400
2018-04-09 08:30:31 7ef7af6c [app] [I] Processing by Api::V2::HostsController#update as JSON
2018-04-09 08:30:31 7ef7af6c [app] [I]   Parameters: {"host"=>{"content_facet_attributes"=>{"lifecycle_environment_id"=>14, "content_view_id"=>11}, "subscription_facet_attributes"=>{"installed_products"=>[{"product_id"=>"69", "product_name"=>"Red Hat Enterprise Linux Server", "arch"=>"x86_64", "version"=>"Hat"}], "service_level"=>nil, "autoheal"=>true}}, "apiv"=>"v2", "id"=>"7"}
2018-04-09 08:30:31 7ef7af6c [app] [I] Current user: foreman_admin (administrator)
2018-04-09 08:30:31 7ef7af6c [app] [I] Authorized user admin(Admin User)
2018-04-09 08:30:31 7ef7af6c [app] [I] Current user: admin (administrator)
2018-04-09 08:30:31 7ef7af6c [app] [I] Expire fragment views/tabs_and_title_records-3 (0.0ms)
2018-04-09 08:30:31 7ef7af6c [app] [I] Expire fragment views/tabs_and_title_records-3 (0.1ms)
2018-04-09 08:30:31 7ef7af6c [app] [W] Action failed
 | ActiveRecord::AssociationTypeMismatch: Katello::InstalledProduct(#80842300) expected, got ActiveSupport::HashWithIndifferentAccess(#12790900)

(see attached foreman-debug tarball for the complete log)


Version-Release number of selected component (if applicable):
6.3.1-2

How reproducible:
always

Steps to Reproduce:
1. get some content hosts with subscriptions attached
2. export the subscriptions to a csv using `hammer csv content-hosts --organization="org1" --export --file="/tmp/chs_export_ao936E.csv"` and modify it slightly
3. try to import the subscrption csv file using `hammer csv content-hosts..`

(for QA: run `py.test -k test_positive_restore_content_hosts_with_modified_subscription test_subscription.py -s`)

Actual results:
 | ActiveRecord::AssociationTypeMismatch: Katello::InstalledProduct(#80842300) expected, got ActiveSupport::HashWithIndifferentAccess(#12790900)

Comment 3 Satellite Program 2018-04-10 02:24:32 UTC
Moving this bug to POST for triage into Satellite 6 since the upstream issue http://projects.theforeman.org/issues/23189 has been resolved.

Comment 8 errata-xmlrpc 2018-04-13 13:32:28 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/RHBA-2018:1126