Bug 1088442

Summary: "bad request" exceptions and their messages are not displayed to hammer user
Product: Red Hat Satellite Reporter: Tom McKay <tomckay>
Component: HammerAssignee: Adam Price <adprice>
Status: CLOSED CURRENTRELEASE QA Contact: Tazim Kolhar <tkolhar>
Severity: medium Docs Contact:
Priority: unspecified    
Version: NightlyCC: bbuckingham, cwelton, daviddavis, kbidarka, tkolhar, tomckay
Target Milestone: UnspecifiedKeywords: Triaged
Target Release: Unused   
Hardware: Unspecified   
OS: Unspecified   
URL: http://projects.theforeman.org/issues/5215
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2014-09-11 12:24:10 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 Tom McKay 2014-04-16 15:57:01 UTC
Try creating an activation key using the same name/label as another. A generic "400 bad request" message is printed instead of indicating that the name is already in use (the server log contains this message).

Two fixes probably needed:
1. hammer-cli-foreman does not handle bad request
2. hammer-cli-katello should make sure the 'displayMessage' gets used in the error type (and all the others?)
   -or-
   katello needs to return json data in the same format as foreman does ('message'?)

Comment 1 Tom McKay 2014-04-16 15:58:12 UTC
Created redmine issue http://projects.theforeman.org/issues/5215 from this bug

Comment 3 David Davis 2014-07-24 13:22:31 UTC
*** Bug 1091313 has been marked as a duplicate of this bug. ***

Comment 4 David Davis 2014-07-24 13:24:14 UTC
For testing this bug, you can use 1091313 as a test case.

Comment 5 Adam Price 2014-08-04 17:55:09 UTC
tom, i'm unable to reproduce this issue. would you mind trying again with your setup?

▶ hammer activation-key create --organization acme --name actkey1
Activation key created
▶ hammer activation-key create --organization acme --name actkey1
Could not create the activation key:
  Validation failed: Name has already been taken

if this issue is more wide-spread than `activation-key create` would you please create a list of the hammer commands which don't display error messages properly? thanks.

Comment 6 David Davis 2014-08-05 16:40:23 UTC
Looks like this was fixed in hammer-cli-katello commit 317f20c7017956d6d0a343b862531ed687c23d16:

https://github.com/Katello/hammer-cli-katello/pull/194/files#diff-69c7957f57f06b23014adb6e7afcfab9R7

Comment 7 Tazim Kolhar 2014-08-08 06:19:09 UTC
VERIFIED

# hammer  activation-key create --help
[Foreman] password for admin: 
Usage:
    hammer activation-key create [OPTIONS]

Options:
    --content-view CONTENT_VIEW_NAME Content view name to search by
    --content-view-id CONTENT_VIEW_ID content view numeric identifier
    --description DESCRIPTION     description
    --lifecycle-environment LIFECYCLE_ENVIRONMENT_NAME Name to search by
    --lifecycle-environment-id LIFECYCLE_ENVIRONMENT_ID  
    --max-content-hosts MAX_CONTENT_HOSTS maximum number of registered content hosts
    --name NAME                   name
    --organization ORGANIZATION_NAME Organization name to search by
    --organization-id ORGANIZATION_ID  
    --organization-label ORGANIZATION_LABEL Organization label to search by
    --unlimited-content-hosts UNLIMITED_CONTENT_HOSTS can the activation key have unlimited content hosts
    -h, --help                    print help

Here,as you see only name and organization is sufficient no option of adding label

# hammer  activation-key create --name act_key --organization testorg 
[Foreman] password for admin: 
Activation key created

Comment 9 Bryan Kearney 2014-09-11 12:24:10 UTC
This was delivered with Satellite 6.0 which was released on 10 September 2014.