fix(anthropic_stream_events): fail closed on malformed upstream UTF-8 (#553) - #873
Open
leseb wants to merge 1 commit into
Open
fix(anthropic_stream_events): fail closed on malformed upstream UTF-8 (#553)#873leseb wants to merge 1 commit into
leseb wants to merge 1 commit into
Conversation
…praxis-proxy#553) Once the filter has emitted Anthropic Messages events, passing malformed OpenAI SSE bytes through unchanged and then resuming transformation produced a single response mixing two incompatible wire formats, leaking raw Chat Completions SSE (including buffered partial event text) to the client. Return a FilterError when the combined buffer contains malformed UTF-8 and discard any buffered SSE line data instead of flushing it, so the transformed stream fails closed. Remove the now-unused passthrough_with_line_buffer helper and CombinedUtf8Chunk::into_bytes. Signed-off-by: Sébastien Han <seb@redhat.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
Once the
anthropic_stream_eventsfilter has begun emitting Anthropic Messages events, malformed or truncated UTF-8 in the upstream OpenAI SSE was passed through raw and transformation then resumed, producing a single response that mixed two incompatible wire formats and leaked raw Chat Completions bytes (including buffered partial event text) to the client. This fails the transformed stream closed with aFilterErroron malformed UTF-8 and discards buffered SSE line data, which is the smallest change that restores protocol consistency.Related issue
Closes #553
Validation
invalid_utf8_rejected,invalid_utf8_after_stream_start_rejected,truncated_utf8_at_end_of_stream_rejected,pending_utf8_rejected_by_none_end_of_stream_body, andmalformed_utf8_discards_partial_sse_buffermake test(full workspace, 0 failures)make lint(clippy-D warnings, deps, docs/README syncs,check-inferenceall green)Checklist
sync-*andcheck-inferencepass.Signed-off-bytrailer.Breaking changes
None. Malformed UTF-8 was already an invalid upstream SSE response; the stream now fails closed instead of emitting a mixed-format response.