Skip to content
This repository has been archived by the owner on May 30, 2024. It is now read-only.

Unable to differentiate non-existent and empty keys in KV store #43

Open
ecklm opened this issue Nov 3, 2022 · 1 comment
Open

Unable to differentiate non-existent and empty keys in KV store #43

ecklm opened this issue Nov 3, 2022 · 1 comment

Comments

@ecklm
Copy link

ecklm commented Nov 3, 2022

On the consul API if I query an existing endpoint for keys, I receive an empty list, whereas if I query a non-existent key, I receive HTTP 404.

Using the python library, however, I can't differentiate the two cases.

Examples

Existing but empty

$ curl http://.../v1/kv/?keys=True -v
...
> GET /v1/kv/?keys=True HTTP/1.1
...
< HTTP/1.1 200 OK
< Content-Type: application/json
< Vary: Accept-Encoding
< X-Consul-Default-Acl-Policy: allow
< X-Consul-Index: 74726
< X-Consul-Knownleader: true
< X-Consul-Lastcontact: 0
< X-Consul-Query-Backend: blocking-query
< Date: Thu, 03 Nov 2022 16:08:47 GMT
< Content-Length: 2
...
[]
>>> c.kv.get('', keys=True)
('74726', None)

Not existing

$ curl http://.../v1/kv/s/?keys=True -v
...
> GET /v1/kv/s/?keys=True HTTP/1.1
...
< HTTP/1.1 404 Not Found
< Vary: Accept-Encoding
< X-Consul-Default-Acl-Policy: allow
< X-Consul-Index: 74726
< X-Consul-Knownleader: true
< X-Consul-Lastcontact: 0
< X-Consul-Query-Backend: blocking-query
< Date: Thu, 03 Nov 2022 16:08:41 GMT
< Content-Length: 0
>>> c.kv.get('s/', keys=True)
('74726', None)
@ecklm
Copy link
Author

ecklm commented Nov 3, 2022

I have investigated the issue. It was introduced in 6f4eb97 where the meaningless map was replaced (exact change: 6f4eb97#diff-87d94b41a52bb393bfca3dc4b47be3807560585a919ef66394f9fe6e20c216c2R2899). The commit doesn't include reasoning, but I think that was a mistake. In this case, the api returns an empty list, which is very different from a None. And this difference is necessary.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant