Bug 1565117 - ISE on importing host subscriptions from a CSV - ActiveRecord::AssociationTypeMismatch: Katello::InstalledProduct expected, got ActiveSupport::HashWithIndifferentAccess
Summary: ISE on importing host subscriptions from a CSV - ActiveRecord::AssociationTyp...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Satellite
Classification: Red Hat
Component: Subscription Management
Version: 6.3.1
Hardware: Unspecified
OS: Unspecified
unspecified
high
Target Milestone: Unspecified
Assignee: Justin Sherrill
QA Contact: Katello QA List
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2018-04-09 12:41 UTC by Roman Plevka
Modified: 2019-09-26 14:05 UTC (History)
4 users (show)

Fixed In Version: tfm-rubygem-katello-3.4.5.64-1
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2018-04-13 13:32:28 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Foreman Issue Tracker 23184 0 None None None 2018-04-09 21:33:15 UTC
Foreman Issue Tracker 23189 0 None None None 2018-04-09 21:33:31 UTC
Red Hat Product Errata RHBA-2018:1126 0 None None None 2018-04-13 13:33:08 UTC

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


Note You need to log in before you can comment on or make changes to this bug.