fix(responses): parse standard SSE framing - #2464
Conversation
Signed-off-by: 0YHR0 <97868579@qq.com>
📄 Knowledge reviewDosu skipped reviewing this PR because your organization has used its |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2464 +/- ##
=======================================
Coverage 84.93% 84.94%
=======================================
Files 154 154
Lines 22423 22433 +10
=======================================
+ Hits 19046 19056 +10
Misses 2222 2222
Partials 1155 1155 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
kanurag94
left a comment
There was a problem hiding this comment.
LGTM
One thing I noticed is that this bug exists in other translators too.
- openai_completions.go:157
- openai_openai.go:195
- openai_speech.go:154
- openai_transcription.go:137
- anthropic_anthropic.go:146
- openai_gcpvertexai.go:318
They split on a single \n and not \n\n. A backend sending data:{} will break them the same way.
Is it possible to create a followup/ or fix them here (create a shared helper).
Signed-off-by: 0YHR0 <97868579@qq.com>
|
@kanurag94 Thanks, I took the shared-helper approach in 4c81fc2. It now accepts both data field forms across the existing stream parsers, and shares LF/CRLF event-boundary handling for the parsers that buffer full events. I also added helper coverage and ran go test ./internal/translator -count=1. Could you please take another look? |
Description
Make all existing translator SSE parsers accept standard event framing while they inspect streamed events for Gateway observability and protocol translation.
Root Cause
Several parsers required a space in
data:lines, although SSE permitsdata:without that optional space. The Responses and Speech parsers also recognized only LF event boundaries, although SSE permits CRLF boundaries.Impact
Client response bytes remain unchanged for passthrough translators. The missing parsing affects Gateway's extracted token usage, resolved response model, tracing chunks, and translated streams.
Fix
Use shared helpers to parse
data:fields and LF or CRLF event boundaries across the affected stream parsers.Related Issue
Fixes #2463
Testing
go test ./internal/translator -count=1