Bug 1370442

Summary: hammer host collection throws 500 internal server error for undefined method `id' for nil:NilClass
Product: Red Hat Satellite Reporter: Anand Agrawal <aagrawal>
Component: Host CollectionsAssignee: satellite6-bugs <satellite6-bugs>
Status: CLOSED DUPLICATE QA Contact: Katello QA List <katello-qa-list>
Severity: medium Docs Contact:
Priority: medium    
Version: 6.2.0CC: bbuckingham, jcallaha
Target Milestone: UnspecifiedKeywords: Triaged
Target Release: Unused   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-08-29 14:49:42 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 Anand Agrawal 2016-08-26 10:45:42 UTC
Description of problem:
Following command - 
hammer -d  host-collection list

returns the below error -

undefined method `id' for nil:NilClass

RestClient::InternalServerError (500 Internal Server Error):
    /home/aagrawal/.rvm/gems/ruby-2.3.0/gems/rest-client-1.8.0/lib/restclient/abstract_response.rb:74:in `return!'
    /home/aagrawal/.rvm/gems/ruby-2.3.0/gems/apipie-bindings-0.0.17/lib/apipie_bindings/api.rb:309:in `block in rest_client_call_block'
    /home/aagrawal/.rvm/gems/ruby-2.3.0/gems/rest-client-1.8.0/lib/restclient/request.rb:493:in `process_result'
    /home/aagrawal/.rvm/gems/ruby-2.3.0/gems/rest-client-1.8.0/lib/restclient/request.rb:421:in `block in transmit'
    /home/aagrawal/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/net/http.rb:853:in `start'
    /home/aagrawal/.rvm/gems/ruby-2.3.0/gems/rest-client-1.8.0/lib/restclient/request.rb:413:in `transmit'
    /home/aagrawal/.rvm/gems/ruby-2.3.0/gems/rest-client-1.8.0/lib/restclient/request.rb:176:in `execute'
    /home/aagrawal/.rvm/gems/ruby-2.3.0/gems/rest-client-1.8.0/lib/restclient/request.rb:41:in `execute'
    /home/aagrawal/.rvm/gems/ruby-2.3.0/gems/rest-client-1.8.0/lib/restclient/resource.rb:51:in `get'
    /home/aagrawal/.rvm/gems/ruby-2.3.0/gems/apipie-bindings-0.0.17/lib/apipie_bindings/api.rb:293:in `call_client'
    /home/aagrawal/.rvm/gems/ruby-2.3.0/gems/apipie-bindings-0.0.17/lib/apipie_bindings/api.rb:222:in `http_call'
    /home/aagrawal/.rvm/gems/ruby-2.3.0/gems/apipie-bindings-0.0.17/lib/apipie_bindings/api.rb:172:in `call_action'
    /home/aagrawal/.rvm/gems/ruby-2.3.0/gems/apipie-bindings-0.0.17/lib/apipie_bindings/api.rb:167:in `call'
    /home/aagrawal/.rvm/gems/ruby-2.3.0/gems/apipie-bindings-0.0.17/lib/apipie_bindings/resource.rb:14:in `call'
    /home/aagrawal/fork_project/new_hammer_repos/hammer-cli/lib/hammer_cli/apipie/command.rb:43:in `send_request'
    /home/aagrawal/fork_project/new_hammer_repos/hammer-cli-foreman/lib/hammer_cli_foreman/commands.rb:190:in `send_request'
    /home/aagrawal/fork_project/new_hammer_repos/hammer-cli-foreman/lib/hammer_cli_foreman/commands.rb:280:in `send_request'
    /home/aagrawal/fork_project/new_hammer_repos/hammer-cli-foreman/lib/hammer_cli_foreman/commands.rb:315:in `retrieve_all'
    /home/aagrawal/fork_project/new_hammer_repos/hammer-cli-foreman/lib/hammer_cli_foreman/commands.rb:299:in `execute'
    /home/aagrawal/.rvm/gems/ruby-2.3.0/gems/clamp-1.0.0/lib/clamp/command.rb:68:in `run'
    /home/aagrawal/fork_project/new_hammer_repos/hammer-cli/lib/hammer_cli/abstract.rb:22:in `run'
    /home/aagrawal/.rvm/gems/ruby-2.3.0/gems/clamp-1.0.0/lib/clamp/subcommand/execution.rb:11:in `execute'
    /home/aagrawal/.rvm/gems/ruby-2.3.0/gems/clamp-1.0.0/lib/clamp/command.rb:68:in `run'
    /home/aagrawal/fork_project/new_hammer_repos/hammer-cli/lib/hammer_cli/abstract.rb:22:in `run'
    /home/aagrawal/.rvm/gems/ruby-2.3.0/gems/clamp-1.0.0/lib/clamp/subcommand/execution.rb:11:in `execute'
    /home/aagrawal/.rvm/gems/ruby-2.3.0/gems/clamp-1.0.0/lib/clamp/command.rb:68:in `run'
    /home/aagrawal/fork_project/new_hammer_repos/hammer-cli/lib/hammer_cli/abstract.rb:22:in `run'
    /home/aagrawal/.rvm/gems/ruby-2.3.0/gems/clamp-1.0.0/lib/clamp/command.rb:133:in `run'
    /home/aagrawal/fork_project/new_hammer_repos/hammer-cli/bin/hammer:125:in `<top (required)>'
    /home/aagrawal/.rvm/gems/ruby-2.3.0/bin/hammer:23:in `load'
    /home/aagrawal/.rvm/gems/ruby-2.3.0/bin/hammer:23:in `<main>'
    /home/aagrawal/.rvm/gems/ruby-2.3.0/bin/ruby_executable_hooks:15:in `eval'
    /home/aagrawal/.rvm/gems/ruby-2.3.0/bin/ruby_executable_hooks:15:in `<main>'

though with organization-id it works fine


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

How reproducible:
Always

Steps to Reproduce:
1. on satellite terminal run below command:
hammer host-collection list

Actual results:

undefined method `id' for nil:NilClass

RestClient::InternalServerError (500 Internal Server Error):
    /home/aagrawal/.rvm/gems/ruby-2.3.0/gems/rest-client-1.8.0/lib/restclient/abstract_response.rb:74:in `return!'
    /home/aagrawal/.rvm/gems/ruby-2.3.0/gems/apipie-bindings-0.0.17/lib/apipie_bindings/api.rb:309:in `block in rest_client_call_block'
   

Expected results:
Host collection list

ID | NAME   | LIMIT | DESCRIPTION
---|--------|-------|------------
   |        |       |            
---|--------|-------|------------


Additional info:

Comment 2 Brad Buckingham 2016-08-29 14:49:42 UTC
The behavior observed is actually the result of an issue in the API.  That issue has been solved in the upstream and will be delivered in a future release of Satellite 6.

*** This bug has been marked as a duplicate of bug 1331875 ***