Skip to content

test(streaming): tolerate Vertex 429 wrapped in MidStreamFallbackError#28669

Merged
yuneng-berri merged 1 commit into
litellm_internal_stagingfrom
litellm_/determined-ramanujan-d2ab4f
May 22, 2026
Merged

test(streaming): tolerate Vertex 429 wrapped in MidStreamFallbackError#28669
yuneng-berri merged 1 commit into
litellm_internal_stagingfrom
litellm_/determined-ramanujan-d2ab4f

Conversation

@yuneng-berri

Copy link
Copy Markdown
Collaborator

What

tests/local_testing/test_streaming.py::test_vertex_ai_stream[vertex_ai_beta] is currently blocking CI when the live Vertex AI endpoint returns 429.

The test has a tolerance for rate limits:

except litellm.RateLimitError as e:
    pass

…but streaming 429s are now (intentionally) wrapped in MidStreamFallbackError by CustomStreamWrapper._handle_stream_fallback_error so the Router can trigger a fallback. The bare RateLimitError catch no longer matches; the generic except Exception → pytest.fail fires instead.

Change

Add a sibling except litellm.exceptions.MidStreamFallbackError clause that swallows the error only when e.original_exception is a RateLimitError, so the test still fails on unrelated streaming errors. Same pattern already used at test_streaming.py:2925.

Test plan

make test-unit passes locally; the targeted test no longer fails on an upstream 429.

Streaming 429s are wrapped in MidStreamFallbackError so the Router can
fall back; the existing 'except litellm.RateLimitError: pass' in
test_vertex_ai_stream no longer matches, causing the generic
pytest.fail branch to fire when upstream Vertex returns 429.

Add a sibling except for MidStreamFallbackError that only swallows it
when e.original_exception is a RateLimitError, so unrelated streaming
failures still fail the test.
@greptile-apps

greptile-apps Bot commented May 22, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR adds a targeted MidStreamFallbackError exception handler to test_vertex_ai_stream so the test no longer fails when a live Vertex AI endpoint returns a 429 that is now wrapped by CustomStreamWrapper._handle_stream_fallback_error.

  • The new except litellm.exceptions.MidStreamFallbackError clause silently passes only when e.original_exception is a RateLimitError, and still calls pytest.fail() for any other wrapped error or a None original exception — preserving the test's ability to catch genuine streaming failures.
  • The pattern mirrors the existing except litellm.RateLimitError: pass directly above it and the pytest.raises((..., MidStreamFallbackError)) usage at line ~2930 in the same file.

Confidence Score: 5/5

Safe to merge — single-file change to a test helper that only widens transient-error tolerance.

The change touches only one test file and one exception-handling block. The MidStreamFallbackError.original_exception attribute is defined and always set (or None, in which case the guard correctly routes to pytest.fail). No production code is altered, and the test's ability to surface real streaming errors is fully preserved.

No files require special attention.

Important Files Changed

Filename Overview
tests/local_testing/test_streaming.py Adds a MidStreamFallbackError catch clause to test_vertex_ai_stream that silently passes only when the wrapped original_exception is a RateLimitError, matching the existing 429-tolerance pattern.

Reviews (1): Last reviewed commit: "test(streaming): tolerate Vertex 429 wra..." | Re-trigger Greptile

@yuneng-berri yuneng-berri enabled auto-merge (squash) May 22, 2026 22:52
@codecov

codecov Bot commented May 22, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@yuneng-berri yuneng-berri merged commit 574ee75 into litellm_internal_staging May 22, 2026
110 of 112 checks passed
fzowl pushed a commit to fzowl/litellm that referenced this pull request Jun 24, 2026
BerriAI#28669)

Streaming 429s are wrapped in MidStreamFallbackError so the Router can
fall back; the existing 'except litellm.RateLimitError: pass' in
test_vertex_ai_stream no longer matches, causing the generic
pytest.fail branch to fire when upstream Vertex returns 429.

Add a sibling except for MidStreamFallbackError that only swallows it
when e.original_exception is a RateLimitError, so unrelated streaming
failures still fail the test.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants