Query serializer silently drops empty-string parameters

未关闭 适合新手
#179 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
82/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
冷清
技术栈
python
领域
api

调研方向

从 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

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

browserbase/sdk-python 的其他 Issue

查看 browserbase/sdk-python 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。