fix: lowercase bool query params on websocket connect#712
Merged
Conversation
urllib.parse.urlencode stringifies Python bools via str() to "True"/"False", which the API rejects with HTTP 400. The four streaming connect paths (listen v1/v2, speak v1, agent v1) all hit this; HTTP raw clients are unaffected because httpx lowercases bools itself. Coerce True/False to "true"/"false" in core/query_encoder.py before urlencode runs. Covers scalar params, list-of-scalars, and bools nested in dict/list query values. Freeze the file via .fernignore and add a regression test pinning the behavior at the encoder layer.
GregHolmes
pushed a commit
that referenced
this pull request
May 12, 2026
🤖 I have created a release *beep* *boop* --- ## [7.1.1](v7.1.0...v7.1.1) (2026-05-12) ### Bug Fixes * lowercase bool query params on websocket connect ([#712](#712)) ([8899609](8899609)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Python's
urllib.parse.urlencodestringifies booleans viastr(), producingTrue/False(capitalized). The four websocket connect methods (
listen.v1,listen.v2,speak.v1,agent.v1) all hand the encoded query dict tourlencode, so anyboolkwarg — e.g.diarize=True— reaches the API as?diarize=Trueand is rejected with HTTP 400.The generated SDK types for these params are
Union[Literal["true","false"], Any]becauseour AsyncAPI schemas declare them as string enums rather than
type: boolean. TheAnyarmlets bools pass mypy without complaint, so the bug only surfaces on the wire. HTTP raw
clients are unaffected because they hand params to httpx, which lowercases bools itself.
Fix
Add
_coerce_query_valueincore/query_encoder.pymappingTrue/Falseto"true"/"false"beforeurlencoderuns. Applied at every scalar leaf site so bools nested inlist/dictquery values are also coerced.isinstance(v, bool)is precise —1/0arenot coerced (regression test confirms).
Not a breaking change: current behavior is "the call returns HTTP 400," so the fix can only
turn broken calls into working ones.
diarize="true"(string) still works identically.query_encoder.pyis Fern-generated; the patch is frozen under the existing"temporarily frozen — manual patches" pattern in
.fernignore, with the unfreeze conditiondocumented in
AGENTS.md.Test plan
tests/custom/test_query_encoder.pydiarize=Trueagainst production — unpatched returned HTTP400 (matching the reported bug); patched opened cleanly
13(listen v1),14(listen v2),15(batch HTTP withdiarize=True),21and24(speak v1),30(agent v1)ruff checkclean on touched files