Bug 1133244

Summary: hammer returns stacktrace when invalid id is given
Product: Red Hat Satellite Reporter: sthirugn <sthirugn>
Component: HammerAssignee: Stephen Benjamin <stbenjam>
Status: CLOSED ERRATA QA Contact: Katello QA List <katello-qa-list>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 6.0.3CC: sthirugn, walden
Target Milestone: UnspecifiedKeywords: Triaged
Target Release: Unused   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-07-27 11:14:32 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 sthirugn@redhat.com 2014-08-23 18:21:53 UTC
Description of problem:


Version-Release number of selected component (if applicable):


How reproducible:


Steps to Reproduce:
1. Install an errata in the content-host:
hammer> content-host errata apply --errata-ids RHSA-2014:0981 --content-host host1.redhat.com --organization-id=3

2. Get errata info for the applied errata but pass content host name instead of content-host-id (see below)
hammer> content-host errata info --id RHSA-2014:0981 --content-host-id host1.redhat.com --organization-id=3
/usr/lib/ruby/gems/1.8/gems/fast_gettext-0.8.0/lib/fast_gettext/vendor/string.rb:56:in `_fast_gettext_old_format_m': malformed format string - %; (ArgumentError)
	from /usr/lib/ruby/gems/1.8/gems/fast_gettext-0.8.0/lib/fast_gettext/vendor/string.rb:56:in `%'
	from /usr/lib/ruby/gems/1.8/gems/hammer_cli-0.1.1/lib/hammer_cli/utils.rb:12:in `format'
	from /usr/lib/ruby/gems/1.8/gems/hammer_cli-0.1.1/lib/hammer_cli/output/adapter/abstract.rb:27:in `print_error'
	from /usr/lib/ruby/gems/1.8/gems/hammer_cli-0.1.1/lib/hammer_cli/output/output.rb:16:in `print_error'
	from /usr/lib/ruby/gems/1.8/gems/hammer_cli-0.1.1/lib/hammer_cli/exception_handler.rb:43:in `print_error'
	from /usr/lib/ruby/gems/1.8/gems/hammer_cli-0.1.1/lib/hammer_cli/exception_handler.rb:60:in `handle_general_exception'
	from /usr/lib/ruby/gems/1.8/gems/hammer_cli-0.1.1/lib/hammer_cli/exception_handler.rb:26:in `send'
	from /usr/lib/ruby/gems/1.8/gems/hammer_cli-0.1.1/lib/hammer_cli/exception_handler.rb:26:in `handle_exception'
	from /usr/lib/ruby/gems/1.8/gems/hammer_cli-0.1.1/lib/hammer_cli/./apipie/../abstract.rb:189:in `handle_exception'
	from /usr/lib/ruby/gems/1.8/gems/hammer_cli-0.1.1/lib/hammer_cli/./apipie/../abstract.rb:26:in `run'
	from /usr/lib/ruby/gems/1.8/gems/clamp-0.6.2/lib/clamp/command.rb:125:in `run'
	from /usr/lib/ruby/gems/1.8/gems/hammer_cli-0.1.1/bin/hammer:102
	from /usr/bin/hammer:19:in `load'
	from /usr/bin/hammer:19


Actual results:
Stack trace as shown above and the hammer shell exited.

Expected results:
Couldn't find system with content-host-id 'host1.redhat.com'

Additional info:

Comment 2 sthirugn@redhat.com 2014-08-23 18:32:27 UTC
Version Tested:
GA Snap 6 - Satellite-6.0.4-RHEL-6-20140820.1

* apr-util-ldap-1.3.9-3.el6_0.1.x86_64
* candlepin-0.9.23-1.el6_5.noarch
* candlepin-common-1.0.1-1.el6_5.noarch
* candlepin-scl-1-5.el6_4.noarch
* candlepin-scl-quartz-2.1.5-5.el6_4.noarch
* candlepin-scl-rhino-1.7R3-1.el6_4.noarch
* candlepin-scl-runtime-1-5.el6_4.noarch
* candlepin-selinux-0.9.23-1.el6_5.noarch
* candlepin-tomcat6-0.9.23-1.el6_5.noarch
* elasticsearch-0.90.10-6.el6sat.noarch
* foreman-1.6.0.41-1.el6sat.noarch
* foreman-compute-1.6.0.41-1.el6sat.noarch
* foreman-gce-1.6.0.41-1.el6sat.noarch
* foreman-libvirt-1.6.0.41-1.el6sat.noarch
* foreman-ovirt-1.6.0.41-1.el6sat.noarch
* foreman-postgresql-1.6.0.41-1.el6sat.noarch
* foreman-proxy-1.6.0.29-1.el6sat.noarch
* foreman-selinux-1.6.0.7-1.el6sat.noarch
* foreman-vmware-1.6.0.41-1.el6sat.noarch
* katello-1.5.0-29.el6sat.noarch
* katello-ca-1.0-1.noarch
* katello-certs-tools-1.5.6-1.el6sat.noarch
* katello-installer-0.0.60-1.el6sat.noarch
* openldap-2.4.23-34.el6_5.1.x86_64
* openldap-devel-2.4.23-34.el6_5.1.x86_64
* pulp-katello-0.3-3.el6sat.noarch
* pulp-nodes-common-2.4.0-0.30.beta.el6sat.noarch
* pulp-nodes-parent-2.4.0-0.30.beta.el6sat.noarch
* pulp-puppet-plugins-2.4.0-0.30.beta.el6sat.noarch
* pulp-puppet-tools-2.4.0-0.30.beta.el6sat.noarch
* pulp-rpm-plugins-2.4.0-0.30.beta.el6sat.noarch
* pulp-selinux-2.4.0-0.30.beta.el6sat.noarch
* pulp-server-2.4.0-0.30.beta.el6sat.noarch
* python-ldap-2.3.10-1.el6.x86_64
* ruby193-rubygem-net-ldap-0.3.1-3.el6sat.noarch
* ruby193-rubygem-runcible-1.1.0-2.el6sat.noarch

Comment 3 sthirugn@redhat.com 2014-08-23 18:34:53 UTC
Note: This happens for apply command as well:

hammer> content-host errata apply --errata-ids RHSA-2014:0981 --content-host-id host1.redhat.com --organization-id=10000
/usr/lib/ruby/gems/1.8/gems/fast_gettext-0.8.0/lib/fast_gettext/vendor/string.rb:56:in `_fast_gettext_old_format_m': malformed format string - %; (ArgumentError)
	from /usr/lib/ruby/gems/1.8/gems/fast_gettext-0.8.0/lib/fast_gettext/vendor/string.rb:56:in `%'
....

Comment 7 Stephen Benjamin 2015-03-06 12:38:55 UTC
If I've understand your bug right, the command given isn't valid:
hammer> content-host errata info --id RHSA-2014:0981 --content-host-id host1.redhat.com --organization-id=3


You should use --content-host, not --content-host-id.

That's pretty universal that this doesn't work, at least on the commands I checked.  If anything, this should maybe be a more universal bug for hammer to validate parameter values for expected types.

Comment 8 Bryan Kearney 2015-03-06 13:03:22 UTC
Moving to POST since upstream bug http://projects.theforeman.org/issues/9503 has been closed
-------------
Anonymous
Applied in changeset commit:katello|33112a4e0713904dbe40a755a94474c352b42a5f.

Comment 9 sthirugn@redhat.com 2015-03-16 14:48:15 UTC
So this is what I tried:
Step 1: Install an errata in a content host - **Worked fine**
hammer > content-host errata apply --errata-ids RHBA-2015:0479 --content-host intel-s3e3432-01.rhts.eng.bos.redhat.com --organization-id=1

Step 2: Retrieve errata info with content-host-id - **Worked fine**
hammer> content-host errata info --id RHBA-2015:0479 --content-host-id 65fec902-255e-46c3-802c-f7ecc9bf2474 --organization-id=1
(worked fine)


Step 3: Retrieve errata info with content-host name - **Worked fine**
hammer> content-host errata info --id RHBA-2015:0479 --content-host intel-s3e3432-01.rhts.eng.bos.redhat.com --organization-id=1
(worked fine)

Step 4: Pass incorrect (or non-existent) content host id - **Worked fine**
hammer> content-host errata info --id RHBA-2015:0479 --content-host-id 65fec902-255e-46c3-802c-f7ecc9bf247434343 --organization-id=1
Couldn't find system '65fec902-255e-46c3-802c-f7ecc9bf247434343'

Step 5: Pass content-host-id instead of content host name - **Worked fine**
hammer> content-host errata info --id RHBA-2015:0479 --content-host 65fec902-255e-46c3-802c-f7ecc9bf2474 --organization-id=1
Error: system not found

Step 6: Pass content-host name instead of content-host-id - **Failed**
hammer> content-host errata info --id RHBA-2015:0479 --content-host-id intel-s3e3432-01.rhts.eng.bos.redhat.com --organization-id=1
(************Traceback error***************)


So look at scenarios 1 through 5 above - everything worked fine.  But scenario 6 throws tracebook to the user which is an undesirable output.  There should be some error message instead like Step 5.

To answer your questions:
- Yes I understand that this is not valid user command - but if it happens we should show an error message instead of traceback :)
- It doesnt make sense to me when Step 5 works correctly but Step 6 is not.  We should maintain consistency

Comment 10 Stephen Benjamin 2015-03-16 14:54:31 UTC
Ok, I made this more generic, we can probably fix this on all the places you'd get a traceback by giving a bad id.

Comment 11 Stephen Benjamin 2016-03-16 14:27:24 UTC
This was fixed as part of the merge of hosts and content hosts.


[vagrant@centos7-devel hammer-cli]$ hammer host errata info --id grinder_test_3 --host-id centos7-devel.example.com
Error: option '--host-id': numeric value is required

Works when specifying --host:

[vagrant@centos7-devel hammer-cli]$ hammer host errata info --id grinder_test_3 --host centos7-devel.example.com
Title:            Test Errata referring to grinder_test_package-3.0
Version:          
Description:      
Status:           
ID:               cd848511-691f-4fb0-b430-5a588375d3f2
Errata ID:        grinder_test_3
Reboot Suggested: false
Updated:          2012-07-25
Issued:           2010-11-07
Release:          
Solution:         
Packages:         grinder_test_package-3.0-1.fc14.noarch


Or specifying the ID:

[vagrant@centos7-devel hammer-cli]$ hammer host errata info --id grinder_test_3 --host-id 1
Title:            Test Errata referring to grinder_test_package-3.0
Version:          
Description:      
Status:           
ID:               cd848511-691f-4fb0-b430-5a588375d3f2
Errata ID:        grinder_test_3
Reboot Suggested: false
Updated:          2012-07-25
Issued:           2010-11-07
Release:          
Solution:         
Packages:         grinder_test_package-3.0-1.fc14.noarch

Comment 12 sthirugn@redhat.com 2016-03-18 19:58:57 UTC
Verified in Satellite 6.2.0-beta-snap4

Comment 15 Bryan Kearney 2016-07-27 11:14:32 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-2016:1501