chore: Decode async HTTP transport responses strictly - #489
Merged
Conversation
keelerm84
approved these changes
Aug 13, 2026
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.
Overview
AsyncHTTPTransport.requestdecoded response bodies witherrors='replace', which silently substitutes invalid bytes with the U+FFFD replacement character. That can mask a corrupt or misconfigured response instead of surfacing it.This decodes strictly (
await response.text(encoding='UTF-8')), matching the sync SDK'sdata.decode('UTF-8'). A malformed body now raises rather than being silently corrupted. BecauseAsyncHTTPTransportis the centralized async HTTP path, this covers both polling and event delivery.The two other findings from the transport review — the missing
allow_redirects=Falseand the absence of a response body-size cap — were triaged as non-divergences from the sync SDK (the SDK deliberately follows redirects on streaming and polling, and the sync SDK reads bodies unbounded), so they were intentionally left unchanged.Note
Overview
Async HTTP transport now decodes response bodies with strict UTF-8 instead of
errors='replace', so invalid bytes raise rather than being silently replaced with U+FFFD.This aligns
AsyncHTTPTransport.requestwith the sync SDK’sdata.decode('UTF-8')behavior and affects all async HTTP callers that use this centralized path (polling and event delivery).Reviewed by Cursor Bugbot for commit 81b76d1. Bugbot is set up for automated code reviews on this repo. Configure here.