Skip to content

Preserve explicit empty query string values - #1857

Open
sylvesterkaczmarek wants to merge 1 commit into
anthropics:mainfrom
sylvesterkaczmarek:fix/preserve-empty-query-values
Open

Preserve explicit empty query string values#1857
sylvesterkaczmarek wants to merge 1 commit into
anthropics:mainfrom
sylvesterkaczmarek:fix/preserve-empty-query-values

Conversation

@sylvesterkaczmarek

Copy link
Copy Markdown

Summary

Preserve explicitly empty string query parameters instead of silently dropping them from the request URL.

Querystring._stringify_item() currently converts a primitive value to a string and then drops it whenever the serialized result is falsy. That intentionally omits None, but it also conflates "" with absence:

  • {"key": None} -> parameter omitted
  • {"key": ""} -> parameter also omitted

HTTP APIs can distinguish a missing parameter from an explicitly blank one (key=), so callers currently cannot express the latter through the SDK query serializer.

The same issue affects nested values and repeat/bracket array entries containing an empty string.

Fix

Make omission depend on the original value being None, not on the truthiness of its serialized representation.

Existing behavior is preserved for None. Explicit empty strings now serialize as key=. All non-empty strings, numbers, booleans, nested mappings, and existing array formatting continue through the same serialization paths as before.

Regression coverage

Adds focused tests covering:

  • a top-level empty string -> blank=;
  • a nested empty string -> filter[name]=;
  • repeat-array empty strings remaining present while None entries stay omitted;
  • bracket-array empty strings with the same behavior;
  • the existing top-level None omission contract.

The production change is confined to the query-string serializer.

@sylvesterkaczmarek
sylvesterkaczmarek requested a review from a team as a code owner August 17, 2026 11:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant