Bug 1133972

Summary: Attempting to import org w/same name as already-existing fails
Product: Red Hat Satellite Reporter: Grant Gainey <ggainey>
Component: TransitionsAssignee: Tomas Lestach <tlestach>
Status: CLOSED CURRENTRELEASE QA Contact: Lukas Pramuk <lpramuk>
Severity: high Docs Contact:
Priority: unspecified    
Version: 6.0.4CC: cperry, ggainey, mkollar, nobody+davido
Target Milestone: Unspecified   
Target Release: Unused   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2014-10-01 12:27:19 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:
Bug Depends On:    
Bug Blocks: 1125243    

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