KV Value Update handles Data wrongly
还没有人认领这个 Issue。
评估
调研方向
从 values.update() 和 metadata.get() 入口点开始,检查 value、metadata 和 Content-Type 的发送方式。使用两个字段重现请求,然后为预期的 metadata 行为添加回归测试。当 metadata 被单独存储且 values.get() 不再将其作为 value 的一部分返回时,即表示完成。
由索引模型根据 Issue 内容生成。
描述
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
- 主要语言
- Python
- 星标
- 509
- 派生
- 150
- 平均合并
- 3 小时 15 分钟
- 30 天内合并 PR
- 1
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
cloudflare/cloudflare-python 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 88/100
cloudflare/cloudflare-python#2747 ·
-
难度 2/5 1-3 小时 新手友好度 65/100
cloudflare/cloudflare-python#2718 · 1 条评论 ·
-
难度 2/5 1-3 小时 新手友好度 74/100
cloudflare/cloudflare-python#2692 · 1 条评论 ·
-
难度 2/5 1-3 小时 新手友好度 68/100
cloudflare/cloudflare-python#2679 · 4 条评论 · 5 个 reaction ·
-
难度 4/5 3-5 天 新手友好度 35/100
cloudflare/cloudflare-python#2745 · 1 条评论 ·
查看 cloudflare/cloudflare-python 的全部 Issue
相似的 Issue
-
bug
难度 2/5 1-3 小时 新手友好度 82/100
-
难度 2/5 1-3 小时 新手友好度 88/100
use-agent-os/agent-os#3314 ·
-
难度 2/5 1-3 小时 新手友好度 75/100
BasedHardware/omi#15662 · 1 条评论 ·
-
documentation help wanted
难度 2/5 1-3 小时 新手友好度 90/100
-
难度 2/5 1-3 小时 新手友好度 62/100
AiursoftWeb/AnduinOS-2#19 ·