Bug 1133972 - Attempting to import org w/same name as already-existing fails
Summary: Attempting to import org w/same name as already-existing fails
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Red Hat Satellite
Classification: Red Hat
Component: Transitions
Version: 6.0.4
Hardware: Unspecified
OS: Unspecified
unspecified
high
Target Milestone: Unspecified
Assignee: Tomas Lestach
QA Contact: Lukas Pramuk
URL:
Whiteboard:
Depends On:
Blocks: stargate-GA-tracker
TreeView+ depends on / blocked
 
Reported: 2014-08-26 14:47 UTC by Grant Gainey
Modified: 2017-02-23 21:01 UTC (History)
4 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2014-10-01 12:27:19 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description Grant Gainey 2014-08-26 14:47:15 UTC
Trying to import an organization, when there is an existing organization with the same name, fails with

Caught NoMethodError:undefined method `first' for nil:NilClass while processing following line:
{"organization"=>"Richlands", "organization_id"=>"2000"}

The problem (I think) is in base.rb

      rescue RestClient::UnprocessableEntity => ue
        error " Creation of #{to_singular(entity_type)} failed."
        errs = JSON.parse(ue.response)['errors']
        uniq = errs.first[0] if errs.first[1].is_a?(Array) && errs.first[1][0] =~ /must be unique/

If 'errs' is nil, the uniq= fails.

To reproduce:

1) Export orgs from Sat5, containing some org, "Foo"
2) In Sat6, create Foo via webui
3) hammer import organization --csv-file /users/csv/containing/Foo
4) Boom.

Need to fix for GA - running into already-named orgs is not unlikely, we need to respond more responsibly

Comment 1 RHEL Program Management 2014-08-26 14:53:35 UTC
Since this issue was entered in Red Hat Bugzilla, the release flag has been
set to ? to ensure that it is properly evaluated for this release.

Comment 3 Tomas Lestach 2014-08-26 15:23:38 UTC
"organization_id"=>"2000" ?
Man, you really created 2000 organizations on your Sat5? :-)

Comment 4 Grant Gainey 2014-08-26 17:17:28 UTC
(In reply to Tomas Lestach from comment #3)
> "organization_id"=>"2000" ?
> Man, you really created 2000 organizations on your Sat5? :-)

Hand-edited so that I could use davido's export without the org-ids colliding with the ones I already had in my Sat6 instance :)

Comment 5 Tomas Lestach 2014-08-28 13:26:12 UTC
Adapting code to an actual exception ...

hammer-cli-import.git: b024521b54766029adf91dcebb5bdafb701ef80b

Comment 8 Matej Kollar 2014-09-04 12:48:12 UTC
verified with rubygem-hammer_cli_import-0.10.4-1

Comment 9 Grant Gainey 2014-10-01 12:27:19 UTC
Released as part of Sat 6.0 GA


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