litellm/tests/integration/streaming
mrinal-berri bc1309f18e
fix(responses): map streamed flex_unavailable errors to 429 not 500 (#50336)
* fix(responses): map streamed flex_unavailable errors to 429 not 500

When OpenAI has no flex capacity, a service_tier flex request fails with type
resource_unavailable / code flex_unavailable. Non-streamed, this arrives as HTTP
429 and litellm raises RateLimitError. Streamed /v1/responses delivers the same
error as an in-stream event, and neither field was in _ERROR_CODE_HTTP_STATUS, so
it defaulted to 500 InternalServerError.

The HTTP status then depended only on stream: one provider outage looked like a
429 or a 500. The 500 reads as a server error in metrics and alerting, and callers
that retry on 429 do not retry it.

Map both resource_unavailable and flex_unavailable to 429 so the streamed path
matches the non-streamed path.

Fixes #49736

* test(responses): cover streamed flex outage end to end for error and response.failed events

Streams the flex_unavailable payload from #49736 through litellm.aresponses with an injected client and asserts a 429 RateLimitError for both in-stream event kinds, matching the non-streamed path

* test(responses): drop explanatory comment from flex status mapping test

* test(integration): cover streamed flex outage status on responses and chat bridge

Drives the flex_unavailable payload from #49736 through a real proxy as an in-stream error event and as response.failed. The native /v1/responses stream fails with rate_limit_exceeded and logs 429, and the chat bridge answers a 429 throttling error, where both reported a 500 before the mapping fix

---------

Co-authored-by: BinYi LIU <bliu1@berkeley.edu>
2026-11-06 09:55:30 -08:00
..
faked_responses_case.py fix(responses): open faked stream items empty so tool arguments and text arrive once (#46533) 2026-10-15 09:35:12 -07:00
test_assistants_evals_stream.py test(integration): pin assistants and evals endpoint contracts (#44734) 2026-10-14 07:08:35 +00:00
test_azure_streaming_function_calls.py test: migrate local_testing SDK and provider tests out of build_and_test (#45760) 2026-10-10 23:14:25 +00:00
test_bedrock_guardrail_background_stream_scan.py feat(guardrails): scan sampled stream windows in the background (#48952) 2026-10-29 12:19:39 -07:00
test_chat_stream_guardrail_error_events.py test(integration): give each owned proxy a private database and Redis by default (#47213) 2026-10-18 03:37:41 +00:00
test_decision_model_buffering.py fix(streaming)!: fail a stream that ends without a finish reason (#47665) 2026-10-31 11:29:26 -07:00
test_decision_model_pipeline_buffering.py fix(guardrails): honor decision model streaming buffering (#46086) 2026-10-12 16:28:22 -07:00
test_fake_stream_reasoning_wire.py fix(bedrock)!: keep reasoning, thinking blocks and the json_mode finish_reason on fake streams (#46863) 2026-10-16 17:27:57 +00:00
test_faked_responses_stream_bridges.py fix(responses): open faked stream items empty so tool arguments and text arrive once (#46533) 2026-10-15 09:35:12 -07:00
test_faked_responses_stream_cache_replay.py fix(responses): open faked stream items empty so tool arguments and text arrive once (#46533) 2026-10-15 09:35:12 -07:00
test_faked_responses_stream_chaos.py test(integration): give each owned proxy a private database and Redis by default (#47213) 2026-10-18 03:37:41 +00:00
test_faked_responses_stream_guardrail_blocks.py fix(responses): open faked stream items empty so tool arguments and text arrive once (#46533) 2026-10-15 09:35:12 -07:00
test_faked_responses_stream_items.py fix(responses): open faked stream items empty so tool arguments and text arrive once (#46533) 2026-10-15 09:35:12 -07:00
test_file_content_streaming.py test(integration): regression tests for July provider translation, routing and streaming bugs (#42693) 2026-09-23 09:51:06 -07:00
test_google_genai_stream_usage_settings_wire.py test(integration): give each owned proxy a private database and Redis by default (#47213) 2026-10-18 03:37:41 +00:00
test_interception_converted_stream_options.py fix(agentic)!: surface a failed agentic follow-up call instead of the pre-loop tool call (#49227) 2026-11-04 02:00:33 +00:00
test_mid_stream_fallback_continuation.py feat(router): mid-stream fallback continuation for chat completions (#41127) 2026-10-16 13:51:32 +00:00
test_noma_v2_streaming_settings.py test(integration): give each owned proxy a private database and Redis by default (#47213) 2026-10-18 03:37:41 +00:00
test_openai_like_stream_usage_wire.py fix(vertex_ai): route Model Garden models through the generateContent adapter (#41836) 2026-10-15 08:06:49 -07:00
test_openai_sdk_plain_chunk_fields.py perf(streaming): cut per-chunk pydantic round trips on openai-compatible streams (#47030) 2026-10-20 02:42:32 +00:00
test_openai_stream_passthrough_fields.py test: migrate SDK and proxy-booting legacy CircleCI tests to their tiers (#45758) 2026-10-11 00:17:21 -07:00
test_responses_bridge_stream_chaos.py test(integration): give each owned proxy a private database and Redis by default (#47213) 2026-10-18 03:37:41 +00:00
test_responses_bridge_stream_errors.py test(integration): give each owned proxy a private database and Redis by default (#47213) 2026-10-18 03:37:41 +00:00
test_responses_top_level_error_events.py fix(responses): map streamed flex_unavailable errors to 429 not 500 (#50336) 2026-11-06 09:55:30 -08:00
test_stream_clean_eof_without_finish_reason.py fix(streaming)!: fail a stream that ends without a finish reason (#47665) 2026-10-31 11:29:26 -07:00
test_stream_contracts.py fix(streaming)!: send the include_usage chunk with an empty choices array (#47109) 2026-10-21 02:26:05 +00:00
test_stream_open_error_provider_headers_proxy.py test(integration): hand every harness server a port from one per-worker block (#46761) 2026-10-15 16:56:40 -07:00
test_stream_parallel_slot_release.py test(integration): regression tests for August provider translation and streaming bugs (#42621) 2026-09-22 20:52:00 -07:00
test_text_completion_stream_guardrail_rebuild.py fix(guardrails): scan and rewrite streamed /v1/completions under post_call guardrails (#49035) 2026-10-29 08:46:49 -07:00
test_ttft_keepalive.py test(integration): regression tests for August provider translation and streaming bugs (#42621) 2026-09-22 20:52:00 -07:00