Skip to content

Commit fe8775e

Browse files
Thom MaySeth Falcon
authored andcommitted
Return 412 if we can't load a dependent cookbook
1 parent b0dc2f7 commit fe8775e

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

‎chef-server-api/app/controllers/nodes.rb‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,11 @@ def cookbooks
105105

106106
def satisfy(cookbook, req=nil)
107107
r = req.to_s
108-
versions = Chef::CookbookVersion.cdb_by_name(cookbook)[cookbook].sort
108+
begin
109+
versions = Chef::CookbookVersion.cdb_by_name(cookbook)[cookbook].sort
110+
rescue NoMethodError
111+
raise PreconditionFailed, "cookbook #{cookbook} does not exist"
112+
end
109113
if r.nil? or r.empty? or r == "latest"
110114
versions
111115
elsif r =~ PATTERN

‎features/chef-client/cookbook_sync.feature‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,5 +48,5 @@ Feature: Synchronize cookbooks from the server
4848
And it includes the recipe 'testcookbook_wrong_metadata'
4949
When I run the chef-client with '-l debug'
5050
Then the run should exit '1'
51-
And 'stdout' should have '412 Precondition Failed: cookbook testcookbook_wrong_metadata depends on cookbook no_such_cookbook, but no_such_cookbook does not exist'
51+
And 'stdout' should have '412 Precondition Failed: cookbook no_such_cookbook does not exist'
5252

0 commit comments

Comments
 (0)