python-consul
python-consul copied to clipboard
c.kv.put('a//b', '1') results in an empty key `a/b`
This is due to kennethreitz/requests#2590 : with Requests v2.x, when PUT /v1/kv/a//b
is redirected to PUT /v1/kv/a/b
, the content data is dropped (and Consul cannot distinguish it from a genuine empty content, returning 200.)
We can either wait for Requests v3.0 to be released or use os.path.normpath()
to rewrite an offending key on our side. I'm not 100% sure if it's valid to rewrite a//b
to a/b
when we think about an abstract notion of a "key" but the current implementation of Consul handles a key as something like a path (as opposed to what's merely passed around as a path) so it's okay at least for now.
a/./b
and a/../b
suffer from the same issue.
Hi!
Sorry for the delay in responding to this. You're right, this is an issue.
It's kinda overkill for python-consul to rely on requests. It could just use python's built in HTTP client. There would just need to be a little juggling to make it work for python 2.6 -> python 3.6.
Would you like to take a stab at creating a pull request?