Skip to content

Query serializer silently drops empty-string parameters #179

Description

@abhinavkr26104

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions