Bug #15706

hammer gives poor error message when :host: in ~/.hammer/cli_config.yml is missing https

Added by Bryan Kearney 11 months ago. Updated 5 months ago.

Status:Closed
Priority:Normal
Assigned To:-
Category:Hammer core
Target version:Foreman - Team Marek backlog
Difficulty: Bugzilla link:1356720
Found in release: Pull request:
Story points-
Velocity based estimate-

Description

Cloned from https://bugzilla.redhat.com/show_bug.cgi?id=1356720
Description of problem:

Installing             Done                                               [100%] [...............................................................................................................................]
  Success!
  * Katello is running at https://satellite.ttc.com
      Initial credentials are admin / redhat
  * To install additional capsule on separate machine continue by running:

      capsule-certs-generate --capsule-fqdn "$CAPSULE" --certs-tar "~/$CAPSULE-certs.tar" 

  The full log is at /var/log/foreman-installer/satellite.log

wget -O /root/Manifest.zip http://file.rdu.redhat.com/~rjerrido/manifests/Sat61_Field_Manifest_Generated_05May2016_2.zip
--2016-07-14 15:45:34--  http://file.rdu.redhat.com/~rjerrido/manifests/Sat61_Field_Manifest_Generated_05May2016_2.zip
Resolving file.rdu.redhat.com (file.rdu.redhat.com)... 10.11.5.7
Connecting to file.rdu.redhat.com (file.rdu.redhat.com)|10.11.5.7|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1265248 (1.2M) [application/zip]
Saving to: ‘/root/Manifest.zip’

100%[=========================================================================================================================================================================>] 1,265,248   1.19MB/s   in 1.0s  

2016-07-14 15:45:35 (1.19 MB/s) - ‘/root/Manifest.zip’ saved [1265248/1265248]

hammer subscription upload --organization "$ORG" --file /root/Manifest.zip
Error: undefined method `request' for #<String:0x000000035bd0f8>

Error message was very unhelpful.
rjerrido noticed I was missing something in ~/.hammer/cli_config.yml:

[root@satellite ~]# file .hammer/cli_config.yml
.hammer/cli_config.yml: ASCII text
[root@satellite ~]# cat .hammer/cli_config.yml
:foreman:
:host: 'satellite.ttc.com'
:username: 'admin'
:password: 'redhat'

I changed :host: to 'https://satellite.ttc.com' and it worked.

Version-Release number of selected component (if applicable):
tfm-rubygem-hammer_cli-0.5.1.10-1.el7sat.noarch

How reproducible:
Always

Steps to Reproduce:
1. On a new install, make sure .hammer/cli_config.yml is set up as above
2. Attempt a hammer command
3. Witness the unhelpful error message

Actual results:
Error: undefined method `request' for #<String:0x000000035bd0f8>

Expected results:
Either https:// is assumed (if it's missing) or an error message that points out a configuration error in .hammer/cli_config.yml should appear

Additional info:

History

#1 Updated by Dominic Cleal 10 months ago

  • Description updated (diff)
  • Status changed from New to Need more information

Please provide debug logs with the stack trace to show the origin of the error and take care to format it, I can't reproduce this on Hammer core where it defaults to HTTP. It may be a plugin bug.

#2 Updated by Tomáš Strachota 7 months ago

  • Category set to Hammer core
  • Status changed from Need more information to New
  • Target version set to Team Marek backlog

It's reproducible only with apipie-bindings < 0.0.17 and rest-client < 1.6.7 (valid version combination). It's fixed in higher versions of apipie-bindings, so we should bump the requirement.

[ERROR 2016-11-09 13:43:42 Exception] Error: undefined method `request' for #<String:0x000000025ab548>
Error: undefined method `request' for #<String:0x000000025ab548>
[ERROR 2016-11-09 13:43:42 Exception] 

NoMethodError (undefined method `request' for #<String:0x000000025ab548>):
    /opt/theforeman/tfm/root/usr/share/gems/gems/rest-client-1.6.7/lib/restclient/exceptions.rb:71:in `method_missing'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli_foreman-0.5.1.9/lib/hammer_cli_foreman/exception_handler.rb:31:in `handle_moved_permanently'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.5.1.11/lib/hammer_cli/exception_handler.rb:28:in `handle_exception'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.5.1.11/lib/hammer_cli/messages.rb:26:in `handle_exception'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.5.1.11/lib/hammer_cli/abstract.rb:26:in `rescue in run'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.5.1.11/lib/hammer_cli/abstract.rb:22:in `run'
    /opt/theforeman/tfm/root/usr/share/gems/gems/clamp-1.0.0/lib/clamp/subcommand/execution.rb:11:in `execute'
    /opt/theforeman/tfm/root/usr/share/gems/gems/clamp-1.0.0/lib/clamp/command.rb:68:in `run'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.5.1.11/lib/hammer_cli/abstract.rb:22:in `run'
    /opt/theforeman/tfm/root/usr/share/gems/gems/clamp-1.0.0/lib/clamp/subcommand/execution.rb:11:in `execute'
    /opt/theforeman/tfm/root/usr/share/gems/gems/clamp-1.0.0/lib/clamp/command.rb:68:in `run'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.5.1.11/lib/hammer_cli/abstract.rb:22:in `run'
    /opt/theforeman/tfm/root/usr/share/gems/gems/clamp-1.0.0/lib/clamp/command.rb:133:in `run'
    /opt/theforeman/tfm/root/usr/share/gems/gems/hammer_cli-0.5.1.11/bin/hammer:125:in `<top (required)>'
    /usr/bin/hammer:23:in `load'
    /usr/bin/hammer:23:in `<main>'

#3 Updated by Tomáš Strachota 5 months ago

  • Status changed from New to Closed

Works fine with hammer 0.9.0 that depends on apipie-bindings >= 0.0.19:

hammer host list                                                                                                                                                                              
Redirection of API call detected.
It seems hammer is configured to use HTTP and the server prefers HTTPS.
Update your server url configuration
you can set 'follow_redirects' to one of :default or :always to enable redirects following

Also available in: Atom PDF