Repository navigation
fix: preserve UTF-8 in logged ReadableStream byte chunks - #2701
Merged
Luca Forstner (lforst) merged 2 commits intoNov 2, 2026
Merged
Luca Forstner (lforst) merged 2 commits into
Luca Forstner (lforst) merged 2 commits into
Conversation
Luca Forstner (lforst)
approved these changes
Nov 2, 2026
Member
|
Thanks! |
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.
Logging a raw
ReadableStream<Uint8Array>can corrupt ordinary Unicode output when a multibyte UTF-8 character crosses chunk boundaries. The publicinitLogger/ spanlog/flushpath currently decodes each byte chunk independently increateFinalValuePassThroughStream; split bytes become replacement characters in the serialized/logs3row. ASCII and the same Unicode text in one chunk are passing controls.Decode byte chunks once with streaming decoder state, use that same text for forwarding and accumulation, and flush the decoder at EOF or before a non-byte chunk. Preserve the existing structured/string chunk order, JSON/reasoning precedence, errors and the application-facing stream branch. This is separate from the existing SSE parser repair in #2091.
Added public logger regressions with a fake Braintrust HTTP boundary, plus every split of two-, three- and four-byte characters, mixed strings/structured chunks, empty inputs, incomplete EOF and error controls. No fabricated provider response or provider e2e coverage is involved. A patch changeset is included and matches this PR title.
Validation:
/logs3output and preservation of the original application consumer.The full monorepo, published-package build, browser runtime and real-provider/e2e matrix were not run.
AI assistance: OpenAI Codex performed source inspection, implementation, local execution and independent AI review. No human code review or upstream approval is claimed.