diff options
author | Luke Kanies <luke@madstop.com> | 2008-07-30 23:19:08 -0500 |
---|---|---|
committer | Luke Kanies <luke@madstop.com> | 2008-07-30 23:19:08 -0500 |
commit | c2c8941de5973137d631c1f90f7c07e54cc89e3d (patch) | |
tree | 1a7ab7d4242ca47b7c851d4a7463a23771c439d1 /lib/puppet | |
parent | 186f3cd34fb7fa3bc1ff683a5178444526259f92 (diff) | |
download | puppet-c2c8941de5973137d631c1f90f7c07e54cc89e3d.tar.gz puppet-c2c8941de5973137d631c1f90f7c07e54cc89e3d.tar.xz puppet-c2c8941de5973137d631c1f90f7c07e54cc89e3d.zip |
Correctly handling when REST searches return nothing.
We return a 404, which the client can correctly handle.
That wasn't the actual problem causing failing tests, of course --
the problem was that one side of our stub was autodetecting
marshal, and the other side was forcing yaml, which strangely didn't
work. It was only happening with searching, though, not finding et al.
The 'search returning nil' problem was a bit of a red herring but
needed to be fixed, too.
Signed-off-by: Luke Kanies <luke@madstop.com>
Diffstat (limited to 'lib/puppet')
-rw-r--r-- | lib/puppet/indirector/rest.rb | 5 | ||||
-rw-r--r-- | lib/puppet/network/http/handler.rb | 4 |
2 files changed, 7 insertions, 2 deletions
diff --git a/lib/puppet/indirector/rest.rb b/lib/puppet/indirector/rest.rb index e59b332c0..a2767d05b 100644 --- a/lib/puppet/indirector/rest.rb +++ b/lib/puppet/indirector/rest.rb @@ -46,7 +46,10 @@ class Puppet::Indirector::REST < Puppet::Indirector::Terminus else path = "/#{indirection.name}s" end - deserialize(network.get(path, headers), true) + unless result = deserialize(network.get(path, headers), true) + return [] + end + return result end def destroy(request) diff --git a/lib/puppet/network/http/handler.rb b/lib/puppet/network/http/handler.rb index 0069933bd..291481acd 100644 --- a/lib/puppet/network/http/handler.rb +++ b/lib/puppet/network/http/handler.rb @@ -82,8 +82,10 @@ module Puppet::Network::HTTP::Handler def do_search(request, response) args = params(request) result = model.search(args) + if result.nil? or (result.is_a?(Array) and result.empty?) + return do_exception(response, "Could not find instances in %s with '%s'" % [model.name, args.inspect], 404) + end - # LAK:FAIL This doesn't work. format = format_to_use(request) set_content_type(response, format) |