{"action":"opened","number":54,"pull_request":{"url":"https://api.github.com/repos/crayfishx/jerakia/pulls/54","id":81969068,"html_url":"https://github.com/crayfishx/jerakia/pull/54","diff_url":"https://github.com/crayfishx/jerakia/pull/54.diff","patch_url":"https://github.com/crayfishx/jerakia/pull/54.patch","issue_url":"https://api.github.com/repos/crayfishx/jerakia/issues/54","number":54,"state":"open","locked":false,"title":"Bug: multiple lookups with hashes sometimes caused exception","user":{"login":"crayfishx","id":837815,"avatar_url":"https://avatars.githubusercontent.com/u/837815?v=3","gravatar_id":"","url":"https://api.github.com/users/crayfishx","html_url":"https://github.com/crayfishx","followers_url":"https://api.github.com/users/crayfishx/followers","following_url":"https://api.github.com/users/crayfishx/following{/other_user}","gists_url":"https://api.github.com/users/crayfishx/gists{/gist_id}","starred_url":"https://api.github.com/users/crayfishx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/crayfishx/subscriptions","organizations_url":"https://api.github.com/users/crayfishx/orgs","repos_url":"https://api.github.com/users/crayfishx/repos","events_url":"https://api.github.com/users/crayfishx/events{/privacy}","received_events_url":"https://api.github.com/users/crayfishx/received_events","type":"User","site_admin":false},"body":"This bug can be simulated by having two lookups, where the first\r\nlookup is valid but returns no data, so the second lookup is used.\r\nIn this scenario, an exception is raised because the first lookup\r\nsets the answers payload to {} and the second lookup tries to\r\nappend to it.\r\n\r\n`test/fixtures/etc/jerakia/policy.d/default.rb` has a policy file\r\nthat simulates it, if you look up a cascading hash using this policy\r\nit will fail with an exception.\r\n\r\nThis commit changes the code flow and gathers all the responses from\r\nall the lookups first, before parsing the answer object.  The policy code to trigger this is:\r\n\r\n```ruby\r\npolicy :default do\r\n\r\n\r\n  lookup :invalid do\r\n    datasource :file, {\r\n      :docroot    => \"test/fixtures/var/lib/jerakia/data\",\r\n      :format     => :yaml,\r\n      :searchpath => [\r\n        \"invalid\",\r\n    ],\r\n    }\r\n  end\r\n\r\n  lookup :default do\r\n    datasource :file, {\r\n      :docroot    => \"test/fixtures/var/lib/jerakia/data\",\r\n      :format     => :yaml,\r\n      :searchpath => [\r\n        \"host/#{scope[:hostname]}\",\r\n        \"env/#{scope[:env]}\",\r\n        \"common\",\r\n    ],\r\n    }\r\n  end\r\nend\r\n```\r\n\r\nWhen looking up a cascading hash where the first lookup will not return a result, but is valid  and there is no `stop` in the lookup...\r\n\r\n```\r\n$ bin/jerakia lookup cities -n test --metadata env:dev --no-schema --type cascade --merge_type hash\r\n```\r\n\r\nWe get the following exception\r\n\r\n```\r\n/Users/craigdunn/git/jerakia/lib/jerakia/launcher.rb:22:in `instance_eval': undefined method `<<' for {}:Hash (NoMethodError)\r\n```","created_at":"2016-08-19T11:52:12Z","updated_at":"2016-08-19T11:52:12Z","closed_at":null,"merged_at":null,"merge_commit_sha":null,"assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/crayfishx/jerakia/milestones/15","html_url":"https://github.com/crayfishx/jerakia/milestones/1.0.2","labels_url":"https://api.github.com/repos/crayfishx/jerakia/milestones/15/labels","id":1951444,"number":15,"title":"1.0.2","description":null,"creator":{"login":"crayfishx","id":837815,"avatar_url":"https://avatars.githubusercontent.com/u/837815?v=3","gravatar_id":"","url":"https://api.github.com/users/crayfishx","html_url":"https://github.com/crayfishx","followers_url":"https://api.github.com/users/crayfishx/followers","following_url":"https://api.github.com/users/crayfishx/following{/other_user}","gists_url":"https://api.github.com/users/crayfishx/gists{/gist_id}","starred_url":"https://api.github.com/users/crayfishx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/crayfishx/subscriptions","organizations_url":"https://api.github.com/users/crayfishx/orgs","repos_url":"https://api.github.com/users/crayfishx/repos","events_url":"https://api.github.com/users/crayfishx/events{/privacy}","received_events_url":"https://api.github.com/users/crayfishx/received_events","type":"User","site_admin":false},"open_issues":1,"closed_issues":0,"state":"open","created_at":"2016-08-19T11:52:09Z","updated_at":"2016-08-19T11:52:12Z","due_on":null,"closed_at":null},"commits_url":"https://api.github.com/repos/crayfishx/jerakia/pulls/54/commits","review_comments_url":"https://api.github.com/repos/crayfishx/jerakia/pulls/54/comments","review_comment_url":"https://api.github.com/repos/crayfishx/jerakia/pulls/comments{/number}","comments_url":"https://api.github.com/repos/crayfishx/jerakia/issues/54/comments","statuses_url":"https://api.github.com/repos/crayfishx/jerakia/statuses/23bac8f084f0b614981cfc9e5840084903de648c","head":{"label":"crayfishx:bug/multi_lookup_hash","ref":"bug/multi_lookup_hash","sha":"23bac8f084f0b614981cfc9e5840084903de648c","user":{"login":"crayfishx","id":837815,"avatar_url":"https://avatars.githubusercontent.com/u/837815?v=3","gravatar_id":"","url":"https://api.github.com/users/crayfishx","html_url":"https://github.com/crayfishx","followers_url":"https://api.github.com/users/crayfishx/followers","following_url":"https://api.github.com/users/crayfishx/following{/other_user}","gists_url":"https://api.github.com/users/crayfishx/gists{/gist_id}","starred_url":"https://api.github.com/users/crayfishx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/crayfishx/subscriptions","organizations_url":"https://api.github.com/users/crayfishx/orgs","repos_url":"https://api.github.com/users/crayfishx/repos","events_url":"https://api.github.com/users/crayfishx/events{/privacy}","received_events_url":"https://api.github.com/users/crayfishx/received_events","type":"User","site_admin":false},"repo":{"id":22378742,"name":"jerakia","full_name":"crayfishx/jerakia","owner":{"login":"crayfishx","id":837815,"avatar_url":"https://avatars.githubusercontent.com/u/837815?v=3","gravatar_id":"","url":"https://api.github.com/users/crayfishx","html_url":"https://github.com/crayfishx","followers_url":"https://api.github.com/users/crayfishx/followers","following_url":"https://api.github.com/users/crayfishx/following{/other_user}","gists_url":"https://api.github.com/users/crayfishx/gists{/gist_id}","starred_url":"https://api.github.com/users/crayfishx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/crayfishx/subscriptions","organizations_url":"https://api.github.com/users/crayfishx/orgs","repos_url":"https://api.github.com/users/crayfishx/repos","events_url":"https://api.github.com/users/crayfishx/events{/privacy}","received_events_url":"https://api.github.com/users/crayfishx/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/crayfishx/jerakia","description":"A pluggable and extendable data lookup system","fork":false,"url":"https://api.github.com/repos/crayfishx/jerakia","forks_url":"https://api.github.com/repos/crayfishx/jerakia/forks","keys_url":"https://api.github.com/repos/crayfishx/jerakia/keys{/key_id}","collaborators_url":"https://api.github.com/repos/crayfishx/jerakia/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/crayfishx/jerakia/teams","hooks_url":"https://api.github.com/repos/crayfishx/jerakia/hooks","issue_events_url":"https://api.github.com/repos/crayfishx/jerakia/issues/events{/number}","events_url":"https://api.github.com/repos/crayfishx/jerakia/events","assignees_url":"https://api.github.com/repos/crayfishx/jerakia/assignees{/user}","branches_url":"https://api.github.com/repos/crayfishx/jerakia/branches{/branch}","tags_url":"https://api.github.com/repos/crayfishx/jerakia/tags","blobs_url":"https://api.github.com/repos/crayfishx/jerakia/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/crayfishx/jerakia/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/crayfishx/jerakia/git/refs{/sha}","trees_url":"https://api.github.com/repos/crayfishx/jerakia/git/trees{/sha}","statuses_url":"https://api.github.com/repos/crayfishx/jerakia/statuses/{sha}","languages_url":"https://api.github.com/repos/crayfishx/jerakia/languages","stargazers_url":"https://api.github.com/repos/crayfishx/jerakia/stargazers","contributors_url":"https://api.github.com/repos/crayfishx/jerakia/contributors","subscribers_url":"https://api.github.com/repos/crayfishx/jerakia/subscribers","subscription_url":"https://api.github.com/repos/crayfishx/jerakia/subscription","commits_url":"https://api.github.com/repos/crayfishx/jerakia/commits{/sha}","git_commits_url":"https://api.github.com/repos/crayfishx/jerakia/git/commits{/sha}","comments_url":"https://api.github.com/repos/crayfishx/jerakia/comments{/number}","issue_comment_url":"https://api.github.com/repos/crayfishx/jerakia/issues/comments{/number}","contents_url":"https://api.github.com/repos/crayfishx/jerakia/contents/{+path}","compare_url":"https://api.github.com/repos/crayfishx/jerakia/compare/{base}...{head}","merges_url":"https://api.github.com/repos/crayfishx/jerakia/merges","archive_url":"https://api.github.com/repos/crayfishx/jerakia/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/crayfishx/jerakia/downloads","issues_url":"https://api.github.com/repos/crayfishx/jerakia/issues{/number}","pulls_url":"https://api.github.com/repos/crayfishx/jerakia/pulls{/number}","milestones_url":"https://api.github.com/repos/crayfishx/jerakia/milestones{/number}","notifications_url":"https://api.github.com/repos/crayfishx/jerakia/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/crayfishx/jerakia/labels{/name}","releases_url":"https://api.github.com/repos/crayfishx/jerakia/releases{/id}","deployments_url":"https://api.github.com/repos/crayfishx/jerakia/deployments","created_at":"2014-07-29T12:18:47Z","updated_at":"2016-06-14T08:58:14Z","pushed_at":"2016-08-19T11:52:12Z","git_url":"git://github.com/crayfishx/jerakia.git","ssh_url":"git@github.com:crayfishx/jerakia.git","clone_url":"https://github.com/crayfishx/jerakia.git","svn_url":"https://github.com/crayfishx/jerakia","homepage":"http://jerakia.io","size":324,"stargazers_count":23,"watchers_count":23,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":6,"mirror_url":null,"open_issues_count":4,"forks":6,"open_issues":4,"watchers":23,"default_branch":"master"}},"base":{"label":"crayfishx:master","ref":"master","sha":"16eeacdc49d52273f077d8170fc5c9921b837e89","user":{"login":"crayfishx","id":837815,"avatar_url":"https://avatars.githubusercontent.com/u/837815?v=3","gravatar_id":"","url":"https://api.github.com/users/crayfishx","html_url":"https://github.com/crayfishx","followers_url":"https://api.github.com/users/crayfishx/followers","following_url":"https://api.github.com/users/crayfishx/following{/other_user}","gists_url":"https://api.github.com/users/crayfishx/gists{/gist_id}","starred_url":"https://api.github.com/users/crayfishx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/crayfishx/subscriptions","organizations_url":"https://api.github.com/users/crayfishx/orgs","repos_url":"https://api.github.com/users/crayfishx/repos","events_url":"https://api.github.com/users/crayfishx/events{/privacy}","received_events_url":"https://api.github.com/users/crayfishx/received_events","type":"User","site_admin":false},"repo":{"id":22378742,"name":"jerakia","full_name":"crayfishx/jerakia","owner":{"login":"crayfishx","id":837815,"avatar_url":"https://avatars.githubusercontent.com/u/837815?v=3","gravatar_id":"","url":"https://api.github.com/users/crayfishx","html_url":"https://github.com/crayfishx","followers_url":"https://api.github.com/users/crayfishx/followers","following_url":"https://api.github.com/users/crayfishx/following{/other_user}","gists_url":"https://api.github.com/users/crayfishx/gists{/gist_id}","starred_url":"https://api.github.com/users/crayfishx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/crayfishx/subscriptions","organizations_url":"https://api.github.com/users/crayfishx/orgs","repos_url":"https://api.github.com/users/crayfishx/repos","events_url":"https://api.github.com/users/crayfishx/events{/privacy}","received_events_url":"https://api.github.com/users/crayfishx/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/crayfishx/jerakia","description":"A pluggable and extendable data lookup system","fork":false,"url":"https://api.github.com/repos/crayfishx/jerakia","forks_url":"https://api.github.com/repos/crayfishx/jerakia/forks","keys_url":"https://api.github.com/repos/crayfishx/jerakia/keys{/key_id}","collaborators_url":"https://api.github.com/repos/crayfishx/jerakia/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/crayfishx/jerakia/teams","hooks_url":"https://api.github.com/repos/crayfishx/jerakia/hooks","issue_events_url":"https://api.github.com/repos/crayfishx/jerakia/issues/events{/number}","events_url":"https://api.github.com/repos/crayfishx/jerakia/events","assignees_url":"https://api.github.com/repos/crayfishx/jerakia/assignees{/user}","branches_url":"https://api.github.com/repos/crayfishx/jerakia/branches{/branch}","tags_url":"https://api.github.com/repos/crayfishx/jerakia/tags","blobs_url":"https://api.github.com/repos/crayfishx/jerakia/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/crayfishx/jerakia/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/crayfishx/jerakia/git/refs{/sha}","trees_url":"https://api.github.com/repos/crayfishx/jerakia/git/trees{/sha}","statuses_url":"https://api.github.com/repos/crayfishx/jerakia/statuses/{sha}","languages_url":"https://api.github.com/repos/crayfishx/jerakia/languages","stargazers_url":"https://api.github.com/repos/crayfishx/jerakia/stargazers","contributors_url":"https://api.github.com/repos/crayfishx/jerakia/contributors","subscribers_url":"https://api.github.com/repos/crayfishx/jerakia/subscribers","subscription_url":"https://api.github.com/repos/crayfishx/jerakia/subscription","commits_url":"https://api.github.com/repos/crayfishx/jerakia/commits{/sha}","git_commits_url":"https://api.github.com/repos/crayfishx/jerakia/git/commits{/sha}","comments_url":"https://api.github.com/repos/crayfishx/jerakia/comments{/number}","issue_comment_url":"https://api.github.com/repos/crayfishx/jerakia/issues/comments{/number}","contents_url":"https://api.github.com/repos/crayfishx/jerakia/contents/{+path}","compare_url":"https://api.github.com/repos/crayfishx/jerakia/compare/{base}...{head}","merges_url":"https://api.github.com/repos/crayfishx/jerakia/merges","archive_url":"https://api.github.com/repos/crayfishx/jerakia/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/crayfishx/jerakia/downloads","issues_url":"https://api.github.com/repos/crayfishx/jerakia/issues{/number}","pulls_url":"https://api.github.com/repos/crayfishx/jerakia/pulls{/number}","milestones_url":"https://api.github.com/repos/crayfishx/jerakia/milestones{/number}","notifications_url":"https://api.github.com/repos/crayfishx/jerakia/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/crayfishx/jerakia/labels{/name}","releases_url":"https://api.github.com/repos/crayfishx/jerakia/releases{/id}","deployments_url":"https://api.github.com/repos/crayfishx/jerakia/deployments","created_at":"2014-07-29T12:18:47Z","updated_at":"2016-06-14T08:58:14Z","pushed_at":"2016-08-19T11:52:12Z","git_url":"git://github.com/crayfishx/jerakia.git","ssh_url":"git@github.com:crayfishx/jerakia.git","clone_url":"https://github.com/crayfishx/jerakia.git","svn_url":"https://github.com/crayfishx/jerakia","homepage":"http://jerakia.io","size":324,"stargazers_count":23,"watchers_count":23,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":6,"mirror_url":null,"open_issues_count":4,"forks":6,"open_issues":4,"watchers":23,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/crayfishx/jerakia/pulls/54"},"html":{"href":"https://github.com/crayfishx/jerakia/pull/54"},"issue":{"href":"https://api.github.com/repos/crayfishx/jerakia/issues/54"},"comments":{"href":"https://api.github.com/repos/crayfishx/jerakia/issues/54/comments"},"review_comments":{"href":"https://api.github.com/repos/crayfishx/jerakia/pulls/54/comments"},"review_comment":{"href":"https://api.github.com/repos/crayfishx/jerakia/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/crayfishx/jerakia/pulls/54/commits"},"statuses":{"href":"https://api.github.com/repos/crayfishx/jerakia/statuses/23bac8f084f0b614981cfc9e5840084903de648c"}},"merged":false,"mergeable":false,"mergeable_state":"dirty","merged_by":null,"comments":0,"review_comments":0,"commits":1,"additions":30,"deletions":13,"changed_files":3}}
{"actor":{"display_login":"crayfishx"}}