Query serializer silently drops empty-string parameters

Open Beginner friendly
#179 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
82/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Quiet
Tech stack
python
Domain
api

Research direction

Start in src/browserbase/_qs.py at lines 97-102 and reproduce the issue with stringify({"q": ""}). Read the existing query-string tests covering booleans, arrays, and nesting, then add coverage for scalar empty strings and confirm the result is q= while intentionally absent values remain omitted.

Written by the indexing model from the issue text.

Description

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.

Dominant language
Python
Stars
93
Forks
16
Avg merge
11m
Merged PRs (30d)
3

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from browserbase/sdk-python

All issues in browserbase/sdk-python

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.