{"action":"opened","issue":{"url":"https://api.github.com/repos/bloomberg/chef-bach/issues/79","labels_url":"https://api.github.com/repos/bloomberg/chef-bach/issues/79/labels{/name}","comments_url":"https://api.github.com/repos/bloomberg/chef-bach/issues/79/comments","events_url":"https://api.github.com/repos/bloomberg/chef-bach/issues/79/events","html_url":"https://github.com/bloomberg/chef-bach/issues/79","id":56612398,"number":79,"title":"get_node_req_attributes fails a chef run with unhelpful \"undefined method `[]' for nil:NilClass\"","user":{"login":"cbaenziger","id":4192761,"avatar_url":"https://avatars.githubusercontent.com/u/4192761?v=3","gravatar_id":"","url":"https://api.github.com/users/cbaenziger","html_url":"https://github.com/cbaenziger","followers_url":"https://api.github.com/users/cbaenziger/followers","following_url":"https://api.github.com/users/cbaenziger/following{/other_user}","gists_url":"https://api.github.com/users/cbaenziger/gists{/gist_id}","starred_url":"https://api.github.com/users/cbaenziger/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cbaenziger/subscriptions","organizations_url":"https://api.github.com/users/cbaenziger/orgs","repos_url":"https://api.github.com/users/cbaenziger/repos","events_url":"https://api.github.com/users/cbaenziger/events{/privacy}","received_events_url":"https://api.github.com/users/cbaenziger/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-02-05T01:00:24Z","updated_at":"2015-02-05T01:00:24Z","closed_at":null,"body":"If one is searching a node for an attribute it does not have, instead of properly erroring out and reporting the node object was incomplete, we today see the following failure:\r\n````\r\n================================================================================\r\nRecipe Compile Error in /var/chef/cache/cookbooks/kafka-bcpc/recipes/setattr.rb\r\n================================================================================\r\n\r\n\r\nNoMethodError\r\n-------------\r\nundefined method `[]' for nil:NilClass\r\n\r\n\r\nCookbook Trace:\r\n---------------\r\n  /var/chef/cache/cookbooks/bcpc-hadoop/libraries/utils.rb:239:in `block (3 levels) in get_req_node_attributes'\r\n  /var/chef/cache/cookbooks/bcpc-hadoop/libraries/utils.rb:239:in `each'\r\n  /var/chef/cache/cookbooks/bcpc-hadoop/libraries/utils.rb:239:in `reduce'\r\n  /var/chef/cache/cookbooks/bcpc-hadoop/libraries/utils.rb:239:in `block (2 levels) in get_req_node_attributes'\r\n  /var/chef/cache/cookbooks/bcpc-hadoop/libraries/utils.rb:238:in `each'\r\n  /var/chef/cache/cookbooks/bcpc-hadoop/libraries/utils.rb:238:in `block in get_req_node_attributes'\r\n  /var/chef/cache/cookbooks/bcpc-hadoop/libraries/utils.rb:236:in `each'\r\n  /var/chef/cache/cookbooks/bcpc-hadoop/libraries/utils.rb:236:in `get_req_node_attributes'\r\n  /var/chef/cache/cookbooks/kafka-bcpc/recipes/setattr.rb:16:in `from_file'\r\n\r\n\r\nRelevant File Content:\r\n----------------------\r\n/var/chef/cache/cookbooks/bcpc-hadoop/libraries/utils.rb:\r\n\r\n232:  # [ { :node_number => \"val\", :hostname => \"nameval\" }, ...]\r\n233:  #\r\n234:  def get_req_node_attributes(node_objects,srch_keys)\r\n235:    result = Array.new\r\n236:    node_objects.each do |obj|\r\n237:      temp = Hash.new\r\n238:      srch_keys.each do |name, key|\r\n239>>       val = key.split('.').reduce(obj) {|memo, key| memo[key]}\r\n240:        temp[name] = val\r\n241:      end\r\n242:      result.push(temp)\r\n243:    end\r\n244:    return result\r\n245:  end\r\n246:\r\n247:  #\r\n248:  # Restarting of hadoop processes need to be controlled in a way that all the nodes\r\n````"}}