KV Value Update handles Data wrongly
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 45/100
Research direction
Start at the values.update() and metadata.get() entry points and inspect how value, metadata, and Content-Type are sent. Reproduce the request with both fields, then add regression coverage for the intended metadata behavior. Done means metadata is stored separately and values.get() no longer returns it as part of the value.
Written by the indexing model from the issue text.
Description
Confirm this is a Python library issue and not an underlying Cloudflare API issue.
- This is an issue with the Python library
Describe the bug
When trying to set a value in the KV Store metadata needs to be provided, but gets merged into the value and no meta data gets set.
In [29]: response = client.kv.namespaces.values.update(key_name="test", value="MY VALUE", metadata="{}", **kv.params)
In [30]: print(client.kv.namespaces.values.get(key_name="test", **kv.params).text())
{"metadata":"{}","value":"MY VALUE"}
In [31]: print(client.kv.namespaces.metadata.get(key_name="test", **kv.params) is None)
True
The problem seems to be caused from the whole body of the request being used as the actual value. The behaviour seems to be correct when manually specifying the request's content tye as multipart/form-data:
In [38]: response = client.kv.namespaces.values.update(key_name="test", value="MY VALUE", metadata="{}", **kv.params, extra_headers={"Content-Type": "multipart/form-data"})
In [39]: print(client.kv.namespaces.values.get(key_name="test", **kv.params).text())
MY VALUE
In [40]: print(client.kv.namespaces.metadata.get(key_name="test", **kv.params))
{}
This should probably be the default behaviour as it shouldn't be necessary to explicitly override the content type. On the other hand metadata should not be required in which case the whole body could be set as value
To Reproduce
- Call
values.update()with avalueandmetadata. Both are set as the actual value. metadata.get()doesn't return any metadata.- Metadata is returned with the value upon calling
values.get().
Code snippets
OS
Every OS
Python version
3.12
Library version
v4.0.0
- Dominant language
- Python
- Stars
- 509
- Forks
- 150
- Avg merge
- 3h 15m
- Merged PRs (30d)
- 1
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from cloudflare/cloudflare-python
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
cloudflare/cloudflare-python#2747 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
cloudflare/cloudflare-python#2718 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
cloudflare/cloudflare-python#2692 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
cloudflare/cloudflare-python#2679 · 4 comments · 5 reactions ·
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
cloudflare/cloudflare-python#2745 · 1 comment ·
All issues in cloudflare/cloudflare-python
Similar issues
-
documentation help wanted
Difficulty 2/5 1-3 hours Newbie friendliness 90/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 90/100
simonw/sqlite-utils#872 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100