Open ulidtko opened 1 month ago
hi @ulidtko this project is kind of abandoned. I don't think anybody is using it at this point in time, so if you want to fix this my suggestion would be to fork
Hey @vdloo, yes I could see that, thanks for responding :smiley:
I don't think anybody is using it at this point in time
Oh boy, how you're wrong here :sweat_smile: I won't publically tell much, but it is very much used, in production systems. We hit this bug there.
Not sure how you'd like to proceed; I'd be completely happy if you decide on adding an EOL notice to README and archiving the repo. Then I could tell teams to stop using it in production.
Fixing the bug, or recommending another consul api wrapper library, are also fine options. Just please, deprecate the package if you don't maintain the code :pray:
I am surprised to hear that, but I am glad it ended up being useful for somebody. Because your issue was well described I have created this pull request here which adds a decode_utf8
parameter to the get methods: https://github.com/vdloo/consul-kv/pull/31. If that works for you I'll merge it.
The code-base is small so if this is an important project for you I would say your best bet is still to fork the code and perhaps maintain it yourself. Alternatives can be found here: https://developer.hashicorp.com/consul/api-docs/libraries-and-sdks.
Consul KV does not guarantee that values are text at all. (Even less so, in any particular encoding, e.g. UTF-8)
Steps to reproduce
:arrow_up: using
curl
with Consul's HTTP API directly, we've written the binary data byte array[0, 1, 2, 3, 4, 5, 222]
to a key/nontext-test
, and read it back. This is as expected :green_circle: :ok_hand:Notice it's not text data! And that's completely fine, Consul KV supports that.
Yet, the python library crashes :boom: if we try to read it:
This code is wrong: https://github.com/vdloo/consul-kv/blob/7beb2c1c84f87ff81bb010ebe49b939d639eccfe/consul_kv/api.py#L151
because it explicitly assumes that the b64-encoded data is always utf-8 text — while Consul provides no such guarantee.
Docs: https://developer.hashicorp.com/consul/api-docs/kv