Title: KV value is returned in bytes rather than string when using Python 3 · Issue #172 · python-consul/python-consul · GitHub
Open Graph Title: KV value is returned in bytes rather than string when using Python 3 · Issue #172 · python-consul/python-consul
X Title: KV value is returned in bytes rather than string when using Python 3 · Issue #172 · python-consul/python-consul
Description: consul_api.kv.get() is supposed to return: { "CreateIndex": 100, "ModifyIndex": 200, "LockIndex": 200, "Key": "foo", "Flags": 0, "Value": "bar", "Session": "adf4238a-882b-9ddc-4a9d-5b6758e4159e" } It is true for Python 2. When using Pyth...
Open Graph Description: consul_api.kv.get() is supposed to return: { "CreateIndex": 100, "ModifyIndex": 200, "LockIndex": 200, "Key": "foo", "Flags": 0, "Value": "bar", "Session": "adf4238a-882b-9ddc-4a9d-5b6758e4159e" } ...
X Description: consul_api.kv.get() is supposed to return: { "CreateIndex": 100, "ModifyIndex": 200, "LockIndex": 200, "Key": "foo", "Flags": 0, "Va...
Opengraph URL: https://github.com/python-consul/python-consul/issues/172
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"KV value is returned in bytes rather than string when using Python 3 ","articleBody":"`consul_api.kv.get()` is supposed to return:\r\n```\r\n {\r\n \"CreateIndex\": 100,\r\n \"ModifyIndex\": 200,\r\n \"LockIndex\": 200,\r\n \"Key\": \"foo\",\r\n \"Flags\": 0,\r\n \"Value\": \"bar\",\r\n \"Session\": \"adf4238a-882b-9ddc-4a9d-5b6758e4159e\"\r\n }\r\n```\r\n\r\nIt is true for Python 2.\r\nWhen using Python 3, there is a minor difference for `Value` field:\r\n```\r\n \"Value\": b'bar',\r\n```\r\nwhich is bytes, not a string.\r\n\r\nThus, it makes Ansible [consul_kv](http://docs.ansible.com/ansible/latest/consul_kv_module.html) module, for example, not working properly as it badly [compares](https://github.com/ansible/ansible/blob/devel/lib/ansible/modules/clustering/consul_kv.py#L201) string value coming from `consul_api.kv.get()`:\r\n```\r\n\u003e\u003e\u003e b'abc' == 'abc'\r\nFalse\r\n```\r\nSuggestion: to return value as a string to make it working for Python 3 the same way as for 2.\r\n```\r\n\u003e\u003e\u003e b'abc'.decode() == 'abc'\r\nTrue\r\n```\r\nI am sure noone is going to put `b'text'` as a value into Consul KV as it will be stored exactly that way which seems to be a garbage.","author":{"url":"https://github.com/roman-vynar","@type":"Person","name":"roman-vynar"},"datePublished":"2017-10-05T20:49:23.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":2},"url":"https://github.com/172/python-consul/issues/172"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:be9d1a0b-6ef2-10e5-7457-d12411920779 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9350:356387:BB3304:F2C84F:696B256F |
| html-safe-nonce | a39f63bee8314ff5e6541c04aefd3d7cd28cd604a8f3734923f93d6be89b4095 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5MzUwOjM1NjM4NzpCQjMzMDQ6RjJDODRGOjY5NkIyNTZGIiwidmlzaXRvcl9pZCI6IjczODU4OTM2NTM5NjUzODMwMjMiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 47c8bb50b167c2f13082120ef7f6e2672421386446a7c4b90611bc5a2f97fda4 |
| hovercard-subject-tag | issue:263261589 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python-consul/python-consul/172/issue_layout |
| twitter:image | https://opengraph.githubassets.com/e705db6250c2ade110a9ec6f752ec013faef17ee6924e62bfc733b54c0542193/python-consul/python-consul/issues/172 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/e705db6250c2ade110a9ec6f752ec013faef17ee6924e62bfc733b54c0542193/python-consul/python-consul/issues/172 |
| og:image:alt | consul_api.kv.get() is supposed to return: { "CreateIndex": 100, "ModifyIndex": 200, "LockIndex": 200, "Key": "foo", "Flags": 0, "Value": "bar", "Session": "adf4238a-882b-9ddc-4a9d-5b6758e4159e" } ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | roman-vynar |
| hostname | github.com |
| expected-hostname | github.com |
| None | 5f99f7c1d70f01da5b93e5ca90303359738944d8ab470e396496262c66e60b8d |
| turbo-cache-control | no-preview |
| go-import | github.com/python-consul/python-consul git https://github.com/python-consul/python-consul.git |
| octolytics-dimension-user_id | 143416393 |
| octolytics-dimension-user_login | python-consul |
| octolytics-dimension-repository_id | 24473148 |
| octolytics-dimension-repository_nwo | python-consul/python-consul |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 24473148 |
| octolytics-dimension-repository_network_root_nwo | python-consul/python-consul |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 82560a55c6b2054555076f46e683151ee28a19bc |
| ui-target | canary-1 |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width