Bug #19676
closedHammer CLI saves unknown string on defaults field on defaults.yml
Description
Cloned from https://bugzilla.redhat.com/show_bug.cgi?id=1452864
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> </pre