From cea07b60649068cd4ef3d9750f74b8ace1f417f5 Mon Sep 17 00:00:00 2001 From: mateo-berri <277851410+mateo-berri@users.noreply.github.com> Date: Tue, 3 Nov 2026 17:03:45 -0800 Subject: [PATCH] test(audio): assert dropped transcription streams by error type and cause on SDK 3 Main's transcription streaming tests matched the upstream transport message, which openai SDK 3 replaces with "Connection error." when a stream read fails. Assert the LiteLLM APIConnectionError and the dropped connection in its cause chain instead, which holds on SDK 2 and 3. --- .../audio_utils/test_transcription_streaming.py | 5 ++++- tests/unit/proxy/proxy_server/test_routes_audio.py | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/tests/unit/litellm_core_utils/audio_utils/test_transcription_streaming.py b/tests/unit/litellm_core_utils/audio_utils/test_transcription_streaming.py index 5296ea3b15a..5b0e061d3f5 100644 --- a/tests/unit/litellm_core_utils/audio_utils/test_transcription_streaming.py +++ b/tests/unit/litellm_core_utils/audio_utils/test_transcription_streaming.py @@ -19,6 +19,7 @@ from litellm.litellm_core_utils.audio_utils.transcription_streaming import ( litellm_exception_mapper, wrap_transcription_stream, ) +from litellm.llms.custom_httpx.transport_errors import TransportErrorKind, chained_transport_error_kind from litellm.types.utils import TranscriptionResponse _STARTED_AT: Final = datetime.datetime(2026, 10, 28, 12, 0, 0) # noqa: DTZ001 # callback timestamps use the legacy naive contract @@ -177,10 +178,12 @@ async def test_a_stream_the_upstream_drops_mid_transcript_raises_a_litellm_error model="openai/gpt-transcribe", file=("sample.wav", b"audio"), stream=True, client=upstream ) - with pytest.raises(litellm.APIConnectionError, match="peer closed connection"): + with pytest.raises(litellm.APIConnectionError) as raised: async for _ in stream: pass + assert chained_transport_error_kind(raised.value) is TransportErrorKind.DROPPED_CONNECTION + class _FailureHookCounter(CustomLogger): def __init__(self) -> None: diff --git a/tests/unit/proxy/proxy_server/test_routes_audio.py b/tests/unit/proxy/proxy_server/test_routes_audio.py index 9fa617c0dc3..4f25546f1bd 100644 --- a/tests/unit/proxy/proxy_server/test_routes_audio.py +++ b/tests/unit/proxy/proxy_server/test_routes_audio.py @@ -1037,7 +1037,7 @@ def test_streamed_transcription_error_mid_stream_ends_with_an_error_event_and_ru assert tuple(frame.get("delta") for frame in frames[:2]) == ("hello ", "world") assert len(frames) == 3 assert data_lines[-1] == "[DONE]" - assert "upstream connection dropped" in frames[2]["error"]["message"] + assert "APIConnectionError" in frames[2]["error"]["message"] assert "/srv/app/stt_stream.py" not in frames[2]["error"]["message"] assert "stt.internal.corp" not in frames[2]["error"]["message"] assert set(frames[2]["error"]) == {"message", "type", "param", "code"}