fix: accept SSE data lines without a space after the colon - #2470
Merged
Conversation
📄 Knowledge reviewDosu skipped reviewing this PR because your organization has used its |
Signed-off-by: Zixin Zhou <zhouzixin@apache.org>
CodePrometheus
force-pushed
the
fix/sse-data-prefix
branch
from
August 1, 2026 13:16
0c790a8 to
207fe34
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2470 +/- ##
==========================================
+ Coverage 85.03% 85.05% +0.02%
==========================================
Files 159 159
Lines 22634 22645 +11
==========================================
+ Hits 19247 19261 +14
+ Misses 2219 2217 -2
+ Partials 1168 1167 -1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
mathetake
approved these changes
Aug 1, 2026
Member
|
/retest |
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.
Description
The space after
data:is optional per the SSE specification, but the translators only matched the spaced form, so a stream sendingdata:{...}had every event silently skipped.The response bytes still reach the client untouched, but the gateway observes nothing: token usage, the resolved response model, and tracing chunks are all lost. In production this looks like requests succeeding while usage is recorded as zero, which breaks usage-based metrics and any downstream cost or quota logic.
This adds
cutSSEFieldPrefix, which strips an SSE field name and removes at most one leading space, and uses it at everydata:read site plus theevent:read site in the Anthropic stream parser. Emitted streams are unchanged and keep the canonical spaced form.Related Issues/PRs (if applicable)
Related to #2149
Special notes for reviewers (if applicable)
The new streaming regression tests fail without the fix: usage comes back all zeros while the response itself passes through normally.