Query serializer silently drops empty-string parameters
还没有人认领这个 Issue。
评估
调研方向
从 src/browserbase/_qs.py 的第 97-102 行开始,使用 stringify({"q": ""}) 重现该问题。阅读现有的 query-string 测试,了解其对布尔值、数组和嵌套的覆盖,然后为标量空字符串添加测试覆盖,并确认结果为 q=,同时有意缺失的值仍然会被省略。
由索引模型根据 Issue 内容生成。
描述
Description
The query serializer drops scalar empty-string values instead of encoding them as an empty query parameter. _primitive_value_to_str("") returns "", then _stringify_item treats the serialized value as falsy and returns no item.
Code reference
src/browserbase/_qs.py:97-102
Reproduction
from browserbase._qs import stringify
print(repr(stringify({"q": ""})))
Actual:
''
Expected:
'q='
The behavior is also inconsistent with a comma-formatted empty list/all-None list, which can retain the key with an empty value.
Expected behavior
Only values intentionally treated as absent should be omitted. A supplied empty string should serialize as key= so generated endpoints and extra_query can distinguish an empty value from a missing parameter.
Why it matters
Some APIs use the distinction between a missing query key and a present-but-empty key. The SDK's documented custom/undocumented request support cannot currently express the latter through normal query options. Existing query-string tests cover booleans, arrays, and nesting, but not empty scalar values.
- 主要语言
- Python
- 星标
- 93
- 派生
- 16
- 平均合并
- 11 分钟
- 30 天内合并 PR
- 3
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
browserbase/sdk-python 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 82/100
browserbase/sdk-python#182 ·
-
难度 2/5 1-3 小时 新手友好度 84/100
browserbase/sdk-python#180 ·
-
难度 2/5 1-3 小时 新手友好度 78/100
browserbase/sdk-python#178 ·
-
难度 2/5 1-3 小时 新手友好度 82/100
browserbase/sdk-python#176 ·
-
难度 2/5 1-3 小时 新手友好度 82/100
browserbase/sdk-python#175 ·
查看 browserbase/sdk-python 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 88/100
-
难度 2/5 1-3 小时 新手友好度 82/100
-
难度 2/5 1-3 小时 新手友好度 78/100
-
enhancement
难度 2/5 1-3 小时 新手友好度 72/100
-
难度 2/5 1-3 小时 新手友好度 74/100