From 574ee7526db6808be3b2e3649da9a69bd2fb40b6 Mon Sep 17 00:00:00 2001 From: yuneng-jiang Date: Fri, 22 May 2026 15:57:29 -0700 Subject: [PATCH] test(streaming): tolerate Vertex 429 wrapped in MidStreamFallbackError (#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. --- tests/local_testing/test_streaming.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/local_testing/test_streaming.py b/tests/local_testing/test_streaming.py index b1a93c380b..10f351714e 100644 --- a/tests/local_testing/test_streaming.py +++ b/tests/local_testing/test_streaming.py @@ -993,6 +993,11 @@ def test_vertex_ai_stream(provider): except litellm.RateLimitError as e: pass + except litellm.exceptions.MidStreamFallbackError as e: + # Streaming 429s are wrapped in MidStreamFallbackError so the + # Router can fall back; treat as a transient rate-limit pass. + if not isinstance(e.original_exception, litellm.RateLimitError): + pytest.fail(f"Error occurred: {e}") except Exception as e: pytest.fail(f"Error occurred: {e}")