python-consul icon indicating copy to clipboard operation
python-consul copied to clipboard

double quote when populating consul KV store

Open zdlgrj opened this issue 8 years ago • 2 comments

We are using this consul library for pulling our ansible/bitbucket-backed configuration file to the consul KV store. One issue that we have been experiencing is, certain type(e.g. String, Obj) of values that populated into the KV store will have the double quotes. For example.

Here is my configuration file:

test:
  testHost: localhost:8080

After populating consul KV store:

image

Which will cause issue when we are trying to bind the consul KV pair to our configuration instance on the service level since the string will includes unexpected double quote.

Any ideas or suggestion?

zdlgrj avatar Sep 21 '16 18:09 zdlgrj

We're experiencing the same issue. Looking through the python-consul source, I don't see where any quoting is being done explicitly, so it looks like this might be coming from the http library?

lepht avatar Sep 22 '16 18:09 lepht

There's a check here to ensure the value being supplied to put is a string or binary type:

https://github.com/cablehead/python-consul/blob/master/consul/base.py#L513

It sounds like coming from ansible you have rich types of some sort? String with a capital S. Is there something that coerces these into raw strings? If so, could that coercion be adding the quotes?

My question may not even make sense, I'm not familiar with the ansible library you're using.

cablehead avatar Dec 18 '16 22:12 cablehead