Skip to content

fix: pass through Anthropic stream errors#1906

Open
xiaolin593 wants to merge 5 commits intoenvoyproxy:mainfrom
xiaolin593:main
Open

fix: pass through Anthropic stream errors#1906
xiaolin593 wants to merge 5 commits intoenvoyproxy:mainfrom
xiaolin593:main

Conversation

@xiaolin593
Copy link
Contributor

@xiaolin593 xiaolin593 commented Mar 1, 2026

Description

In handleAnthropicStreamEvent, error events now forward Anthropic’s raw error payload (for example overloaded_error). Streaming no longer fails when a valid Anthropic error event is received; subsequent stream events are still processed and emitted.

Related Issues/PRs (if applicable)

Related PR: #984 where original commit was. #1648 simply moved the function.

Signed-off-by: Xiaolin Lin <xlin158@bloomberg.net>
@xiaolin593 xiaolin593 requested a review from a team as a code owner March 1, 2026 03:16
@dosubot dosubot bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Mar 1, 2026
@xiaolin593 xiaolin593 changed the title fix: Pass through Anthropic stream errors fix: pass through Anthropic stream errors Mar 1, 2026
@codecov-commenter
Copy link

codecov-commenter commented Mar 1, 2026

Codecov Report

❌ Patch coverage is 77.77778% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 84.22%. Comparing base (9683c9e) to head (c69b1d4).
⚠️ Report is 9 commits behind head on main.

Files with missing lines Patch % Lines
internal/translator/anthropic_helper.go 77.77% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1906      +/-   ##
==========================================
+ Coverage   84.21%   84.22%   +0.01%     
==========================================
  Files         128      128              
  Lines       17723    17731       +8     
==========================================
+ Hits        14925    14934       +9     
  Misses       1857     1857              
+ Partials      941      940       -1     

☔ View full report in Codecov by Sentry.
📢 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.

@hustxiayang
Copy link
Contributor

  1. would it be better that users can ignore it if we choose to continue with the stream 2) is it safe that we always continue the stream for anthropic errors during stream?

if errors.As(err, &streamErr) {
*buf = append(*buf, sseDataPrefix...)
*buf = append(*buf, streamErr.payload...)
*buf = append(*buf, '\n', '\n')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we still append the DONE event after the error type event?

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.

4 participants