Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
Red Hat Satellite engineering is moving the tracking of its product development work on Satellite to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "Satellite project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs will be migrated starting at the end of May. If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "Satellite project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/SAT-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.

Bug 1452864

Summary: Hammer CLI saves unknown string on defaults field on defaults.yml
Product: Red Hat Satellite Reporter: Diogo Henrique <dnunes>
Component: HammerAssignee: Tomas Strachota <tstrachota>
Status: CLOSED ERRATA QA Contact: Peter Ondrejka <pondrejk>
Severity: low Docs Contact:
Priority: unspecified    
Version: 6.2.9CC: bbuckingham, bkearney, dhlavacd, ehelms, jcallaha, mhulan, tstrachota, zhunting
Target Milestone: UnspecifiedKeywords: Triaged
Target Release: Unused   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2018-02-21 17:00:05 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 Diogo Henrique 2017-05-19 18:46:13 UTC
Description of problem:

When using Hammer commands from within hammer shell, when adding new organization_id default, shell creates a unknown string in name field, making any attempt of starting hammer CLI command and/OR Hammer shell break 


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

tfm-rubygem-hammer_cli-0.5.1.13-2.el7sat.noarch


How reproducible:

On a user without defaults.yml (Don't test with an existent defaults.yml file), run commands in this order:

[root@sat-master .hammer]# hammer shell
Welcome to the hammer interactive shell
Type 'help' for usage information
hammer> defaults list 
----------|------
PARAMETER | VALUE
----------|------
hammer> defaults add --param-name organization_id --param-value 1
Added organization_id default-option with value 1.
hammer> defaults list
----------|------
PARAMETER | VALUE
----------|------
hammer> 
[root@sat-master .hammer]# cat defaults.yml 
---
:defaults:
  :organization_id:
    :value: !ruby/string:HammerCLI::CompleterWord
      str: '1'
      original: '1'


Steps to Reproduce:
1. Steps are provided above

Actual results:

This error is presented when invoking shell or any command from bash after adding a default value to organization_id:

[root@sat-master .hammer]# hammer shell
/opt/rh/rh-ruby22/root/usr/share/ruby/psych/class_loader.rb:53:in `path2class': undefined class/module HammerCLI::CompleterWord (ArgumentError)
	from /opt/rh/rh-ruby22/root/usr/share/ruby/psych/class_loader.rb:53:in `resolve'
	from /opt/rh/rh-ruby22/root/usr/share/ruby/psych/class_loader.rb:45:in `find'
	from /opt/rh/rh-ruby22/root/usr/share/ruby/psych/class_loader.rb:27:in `load'
	from /opt/rh/rh-ruby22/root/usr/share/ruby/psych/visitors/to_ruby.rb:379:in `resolve_class'
	from /opt/rh/rh-ruby22/root/usr/share/ruby/psych/visitors/to_ruby.rb:212:in `visit_Psych_Nodes_Mapping'
	from /opt/rh/rh-ruby22/root/usr/share/ruby/psych/visitors/visitor.rb:15:in `visit'
	from /opt/rh/rh-ruby22/root/usr/share/ruby/psych/visitors/visitor.rb:5:in `accept'
	from /opt/rh/rh-ruby22/root/usr/share/ruby/psych/visitors/to_ruby.rb:31:in `accept'
	from /opt/rh/rh-ruby22/root/usr/share/ruby/psych/visitors/to_ruby.rb:321:in `block in revive_hash'
	from /opt/rh/rh-ruby22/root/usr/share/ruby/psych/visitors/to_ruby.rb:319:in `each'
	from /opt/rh/rh-ruby22/root/usr/share/ruby/psych/visitors/to_ruby.rb:319:in `each_slice'
	from /opt/rh/rh-ruby22/root/usr/share/ruby/psych/visitors/to_ruby.rb:319:in `revive_hash'
	from /opt/rh/rh-ruby22/root/usr/share/ruby/psych/visitors/to_ruby.rb:161:in `visit_Psych_Nodes_Mapping'
	from /opt/rh/rh-ruby22/root/usr/share/ruby/psych/visitors/visitor.rb:15:in `visit'
	from /opt/rh/rh-ruby22/root/usr/share/ruby/psych/visitors/visitor.rb:5:in `accept'
	from /opt/rh/rh-ruby22/root/usr/share/ruby/psych/visitors/to_ruby.rb:31:in `accept'
	from /opt/rh/rh-ruby22/root/usr/share/ruby/psych/visitors/to_ruby.rb:321:in `block in revive_hash'
	from /opt/rh/rh-ruby22/root/usr/share/ruby/psych/visitors/to_ruby.rb:319:in `each'
	from /opt/rh/rh-ruby22/root/usr/share/ruby/psych/visitors/to_ruby.rb:319:in `each_slice'
	from /opt/rh/rh-ruby22/root/usr/share/ruby/psych/visitors/to_ruby.rb:319:in `revive_hash'
	from /opt/rh/rh-ruby22/root/usr/share/ruby/psych/visitors/to_ruby.rb:161:in `visit_Psych_Nodes_Mapping'
	from /opt/rh/rh-ruby22/root/usr/share/ruby/psych/visitors/visitor.rb:15:in `visit'
	from /opt/rh/rh-ruby22/root/usr/share/ruby/psych/visitors/visitor.rb:5:in `accept'
	from /opt/rh/rh-ruby22/root/usr/share/ruby/psych/visitors/to_ruby.rb:31:in `accept'
	from /opt/rh/rh-ruby22/root/usr/share/ruby/psych/visitors/to_ruby.rb:321:in `block in revive_hash'
	from /opt/rh/rh-ruby22/root/usr/share/ruby/psych/visitors/to_ruby.rb:319:in `each'
	from /opt/rh/rh-ruby22/root/usr/share/ruby/psych/visitors/to_ruby.rb:319:in `each_slice'
	from /opt/rh/rh-ruby22/root/usr/share/ruby/psych/visitors/to_ruby.rb:319:in `revive_hash'
	from /opt/rh/rh-ruby22/root/usr/share/ruby/psych/visitors/to_ruby.rb:161:in `visit_Psych_Nodes_Mapping'
	from /opt/rh/rh-ruby22/root/usr/share/ruby/psych/visitors/visitor.rb:15:in `visit'
	from /opt/rh/rh-ruby22/root/usr/share/ruby/psych/visitors/visitor.rb:5:in `accept'
	from /opt/rh/rh-ruby22/root/usr/share/ruby/psych/visitors/to_ruby.rb:31:in `accept'
	from /opt/rh/rh-ruby22/root/usr/share/ruby/psych/visitors/to_ruby.rb:295:in `visit_Psych_Nodes_Document'
	from /opt/rh/rh-ruby22/root/usr/share/ruby/psych/visitors/visitor.rb:15:in `visit'
	from /opt/rh/rh-ruby22/root/usr/share/ruby/psych/visitors/visitor.rb:5:in `accept'
	from /opt/rh/rh-ruby22/root/usr/share/ruby/psych/visitors/to_ruby.rb:31:in `accept'
	from /opt/rh/rh-ruby22/root/usr/share/ruby/psych/nodes/node.rb:37:in `to_ruby'
	from /opt/rh/rh-ruby22/root/usr/share/ruby/psych.rb:246:in `load'
	from /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.5.1.13/lib/hammer_cli/settings.rb:37:in `load_from_file'
	from /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.5.1.13/lib/hammer_cli/settings.rb:21:in `block in load_from_paths'
	from /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.5.1.13/lib/hammer_cli/settings.rb:16:in `each'
	from /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.5.1.13/lib/hammer_cli/settings.rb:16:in `load_from_paths'
	from /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.5.1.13/bin/hammer:49:in `<top (required)>'
	from /usr/bin/hammer:23:in `load'
	from /usr/bin/hammer:23:in `<main>'

Expected results:

Default values added without any problem to defaults.yml file and hammer shell or hammer CLI runs without any problem.

Additional info:

Workaround:

-- Delete 'corrupted' defaults.yml file;
-- Run default command from bash itself:

[root@sat-master .hammer]# hammer defaults add --param-name organization_id  --param-value 1
Added organization_id default-option with value 1.
[root@sat-master .hammer]# ls
defaults.yml  history  log
[root@sat-master .hammer]# cat defaults.yml 
---
:defaults:
  :organization_id:
    :value: '1'
[root@sat-master .hammer]# hammer shell
Welcome to the hammer interactive shell
Type 'help' for usage information
hammer>

Comment 4 Tomas Strachota 2017-05-26 07:16:05 UTC
Created redmine issue http://projects.theforeman.org/issues/19676 from this bug

Comment 5 Satellite Program 2017-05-26 08:18:04 UTC
Upstream bug assigned to tstrachota

Comment 6 Satellite Program 2017-05-26 08:18:08 UTC
Upstream bug assigned to tstrachota

Comment 7 Satellite Program 2017-08-04 20:17:51 UTC
Moving this bug to POST for triage into Satellite 6 since the upstream issue http://projects.theforeman.org/issues/19676 has been resolved.

Comment 9 Peter Ondrejka 2017-11-14 10:16:02 UTC
Verified on Sat 6.3 snap 24

Comment 10 Bryan Kearney 2018-02-21 17:00:05 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/RHSA-2018:0336