agent: Key list of root returns empty list with 200 instead of 404
This commit is contained in:
parent
ee1eefc997
commit
cd08e81958
|
@ -95,11 +95,17 @@ func (s *HTTPServer) KVSGetKeys(resp http.ResponseWriter, req *http.Request, arg
|
||||||
}
|
}
|
||||||
setMeta(resp, &out.QueryMeta)
|
setMeta(resp, &out.QueryMeta)
|
||||||
|
|
||||||
// Check if we get a not found
|
// Check if we get a not found. We do not generate
|
||||||
if len(out.Keys) == 0 {
|
// not found for the root, but just provide the empty list
|
||||||
|
if len(out.Keys) == 0 && listArgs.Prefix != "" {
|
||||||
resp.WriteHeader(404)
|
resp.WriteHeader(404)
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Use empty list instead of null
|
||||||
|
if out.Keys == nil {
|
||||||
|
out.Keys = []string{}
|
||||||
|
}
|
||||||
return out.Keys, nil
|
return out.Keys, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue