Bugzilla will be upgraded to version 5.0. The upgrade date is tentatively scheduled for 2 December 2018, pending final testing and feedback.
Bug 1565117 - ISE on importing host subscriptions from a CSV - ActiveRecord::AssociationTypeMismatch: Katello::InstalledProduct expected, got ActiveSupport::HashWithIndifferentAccess
ISE on importing host subscriptions from a CSV - ActiveRecord::AssociationTyp...
Status: CLOSED ERRATA
Product: Red Hat Satellite 6
Classification: Red Hat
Component: Subscription Management (Show other bugs)
6.3.1
Unspecified Unspecified
unspecified Severity high (vote)
: 6.3.1
: Unused
Assigned To: Justin Sherrill
Katello QA List
: Regression, Triaged
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2018-04-09 08:41 EDT by Roman Plevka
Modified: 2018-08-30 13:29 EDT (History)
4 users (show)

See Also:
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 09:32:28 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)


External Trackers
Tracker ID Priority Status Summary Last Updated
Foreman Issue Tracker 23184 None None None 2018-04-09 17:33 EDT
Foreman Issue Tracker 23189 None None None 2018-04-09 17:33 EDT
Red Hat Product Errata RHBA-2018:1126 None None None 2018-04-13 09:33 EDT

  None (edit)
Description Roman Plevka 2018-04-09 08:41:08 EDT
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 pm-sat@redhat.com 2018-04-09 22:24:32 EDT
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 09:32:28 EDT
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.