From 2898a8e64e32c54d9dcf7fd8b4ed7de7e847cdfc Mon Sep 17 00:00:00 2001 From: Armon Dadgar Date: Wed, 30 Apr 2014 14:21:02 -0700 Subject: [PATCH] agent: Key list of root returns empty list with 200 instead of 404 --- command/agent/kvs_endpoint.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/command/agent/kvs_endpoint.go b/command/agent/kvs_endpoint.go index 2a47e9a1b4..564707566a 100644 --- a/command/agent/kvs_endpoint.go +++ b/command/agent/kvs_endpoint.go @@ -95,11 +95,17 @@ func (s *HTTPServer) KVSGetKeys(resp http.ResponseWriter, req *http.Request, arg } setMeta(resp, &out.QueryMeta) - // Check if we get a not found - if len(out.Keys) == 0 { + // Check if we get a not found. We do not generate + // not found for the root, but just provide the empty list + if len(out.Keys) == 0 && listArgs.Prefix != "" { resp.WriteHeader(404) return nil, nil } + + // Use empty list instead of null + if out.Keys == nil { + out.Keys = []string{} + } return out.Keys, nil }