Skip to content

fix: accept SSE data lines without a space after the colon - #2470

Merged
mathetake merged 1 commit into
envoyproxy:mainfrom
CodePrometheus:fix/sse-data-prefix
Aug 2, 2026
Merged

fix: accept SSE data lines without a space after the colon#2470
mathetake merged 1 commit into
envoyproxy:mainfrom
CodePrometheus:fix/sse-data-prefix

Conversation

@CodePrometheus

Copy link
Copy Markdown
Contributor

Description

The space after data: is optional per the SSE specification, but the translators only matched the spaced form, so a stream sending data:{...} 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 every data: read site plus the event: 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.

@CodePrometheus
CodePrometheus requested a review from a team as a code owner August 1, 2026 13:13
@dosubot dosubot Bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Aug 1, 2026
@dosubot

dosubot Bot commented Aug 1, 2026

Copy link
Copy Markdown

📄 Knowledge review

Dosu skipped reviewing this PR because your organization has used its 200 included credits for the month. Your usage will reset on 2026-09-01. To have Dosu review this PR before then, ask your organization admin to upgrade to a pro account.


Leave Feedback Ask Dosu about ai-gateway Add Dosu to your team

Signed-off-by: Zixin Zhou <zhouzixin@apache.org>
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 93.93939% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 85.05%. Comparing base (b80bc3e) to head (207fe34).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
internal/translator/openai_responses.go 50.00% 0 Missing and 1 partial ⚠️
internal/translator/openai_speech.go 50.00% 0 Missing and 1 partial ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@mathetake

Copy link
Copy Markdown
Member

/retest

@mathetake
mathetake enabled auto-merge (squash) August 1, 2026 23:49
@mathetake
mathetake merged commit 25afc17 into envoyproxy:main Aug 2, 2026
54 of 57 checks passed
@CodePrometheus
CodePrometheus deleted the fix/sse-data-prefix branch August 2, 2026 05:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants