litellm/tests/unit/proxy/pass_through_endpoints
ryan-crabbe-berri b86683679b
fix(vertex_ai): fail Gemini malformed replies with no output so retries and fallbacks run (#53231)
* test(vertex_ai): cover Gemini malformed replies with no output

A non-streaming Gemini reply that ends in MALFORMED_FUNCTION_CALL or MALFORMED_RESPONSE with no output comes back as a 200 stop with empty content, so retries and fallbacks never run. These tests expect a retriable 500 on chat completions, messages and responses, a fallback to the backup model, and billed tokens on the failure log, while replies with any output keep their 200.

* fix(vertex_ai): fail Gemini malformed replies with no output so retries run

When every Gemini candidate ends in MALFORMED_FUNCTION_CALL or MALFORMED_RESPONSE with no text, tool call, image or audio, raise a 500 that names the finish reason instead of returning a 200 stop with empty content. The failure log keeps the tokens Google billed. Replies with any output keep today's shape.

* fix(vertex_ai): keep Gemini pass-through spend logs and bill the failed attempt like other 200 errors

The malformed check now runs only on the live completion path, so the Gemini and Vertex pass-through loggers still bill a malformed reply instead of failing to log it. The failed attempt is recorded the same way OpenRouter records an error inside a 200, so a later retry or fallback can carry it. Tests now cover image, audio and legacy function-call output, the pass-through spend, and a smaller integration matrix on gemini-4-carbon.

* fix(vertex_ai): type the native finish reason read in the Gemini malformed check

* refactor(vertex_ai): return the Gemini malformed failure as a value and raise it at the request boundary

* fix(vertex_ai): keep token counts out of the Gemini malformed error so it is never remapped to a client error

The Vertex error mapper reads a bare 403 in the message as a permission error, so a reply that billed exactly 403 tokens would have skipped retries. The billed tokens stay on the spend log.
2026-11-21 09:49:27 -08:00
..
llm_provider_handlers fix(vertex_ai): fail Gemini malformed replies with no output so retries and fallbacks run (#53231) 2026-11-21 09:49:27 -08:00
__init__.py test(proxy): move middleware, spend_tracking, pass_through, common_utils and root proxy tests into tests/unit/proxy (#44015) 2026-10-01 18:23:31 +00:00
test_carry_guardrail_logging_info.py test(proxy): move middleware, spend_tracking, pass_through, common_utils and root proxy tests into tests/unit/proxy (#44015) 2026-10-01 18:23:31 +00:00
test_codex_passthrough_endpoints.py refactor(auth_cache): type auth cache keys and keep the cache always native (#51130) 2026-11-21 17:20:30 +09:00
test_cursor_cli_passthrough_endpoints.py refactor(auth_cache): type auth cache keys and keep the cache always native (#51130) 2026-11-21 17:20:30 +09:00
test_deepgram_ws_passthrough_routes.py test(auth): use the production cache in auth fixtures (#52754) 2026-11-19 03:43:24 +00:00
test_injected_stream_usage.py fix(vllm): write spend log rows for /vllm passthrough calls to router models (#45733) 2026-10-14 12:40:48 -07:00
test_llm_pass_through_endpoints.py refactor(auth_cache): type auth cache keys and keep the cache always native (#51130) 2026-11-21 17:20:30 +09:00
test_llm_passthrough_endpoints.py fix(proxy): close encoded and backslash paths that skip the Gemini pass-through file ownership check (#53210) 2026-11-20 15:08:57 -08:00
test_managed_id_rewriter.py fix(streaming): keep merged think tags balanced and split SSE lines only on CR/LF (#48755) 2026-10-28 17:00:29 -07:00
test_method_specific_routing.py test(proxy): move middleware, spend_tracking, pass_through, common_utils and root proxy tests into tests/unit/proxy (#44015) 2026-10-01 18:23:31 +00:00
test_pass_through_endpoints.py refactor(auth_cache): type auth cache keys and keep the cache always native (#51130) 2026-11-21 17:20:30 +09:00
test_passthrough_auth_default.py feat(auth): decide key and JWT authentication in a Rust core (#51374) 2026-11-17 14:07:47 +09:00
test_passthrough_endpoint_router.py feat(pass-through): add eu/jev decision API pass-through with spend tracking (#46875) 2026-10-29 17:52:43 -07:00
test_passthrough_endpoints_common_utils.py test(proxy): move middleware, spend_tracking, pass_through, common_utils and root proxy tests into tests/unit/proxy (#44015) 2026-10-01 18:23:31 +00:00
test_passthrough_guardrail_block_otel_span.py refactor(auth_cache): type auth cache keys and keep the cache always native (#51130) 2026-11-21 17:20:30 +09:00
test_passthrough_guardrails.py fix(responses): run the guardrails a Responses WebSocket frame selects (#48725) 2026-10-30 14:12:51 -07:00
test_passthrough_guardrails_field_targeting.py test(proxy): move middleware, spend_tracking, pass_through, common_utils and root proxy tests into tests/unit/proxy (#44015) 2026-10-01 18:23:31 +00:00
test_passthrough_post_call_guardrails.py refactor(proxy): expose public names for private proxy helpers (#45170) 2026-10-07 18:59:27 -07:00
test_streaming_handler.py feat(anthropic): price Claude subscription OAuth allowance usage at $0, overage at API rates (#52901) 2026-11-19 15:08:39 -08:00
test_streaming_handler_interrupt.py feat(proxy): per-request header opts a stream into usage.cost without the global include_cost_in_streaming_usage flag (#50574) 2026-11-07 16:57:20 -08:00
test_success_handler.py feat(budgets): replace the python budget hold and settle engine with a rust engine admitted at auth (#51535) 2026-11-15 16:03:51 -08:00
test_upstream_usage_headers.py fix(otel): label configured pass-through routes litellm.passthrough and read the operation from the upstream (#48675) 2026-10-28 10:48:34 -07:00
test_vector_store_fallbacks.py feat(vector-stores): fail over native search passthrough to configured fallback stores (#52856) 2026-11-19 09:51:41 -08:00
test_vertex_ai_batch_passthrough.py refactor(router): move router callers onto the entry points and invert the proxy imports (#48847) 2026-10-29 17:26:33 +00:00
test_vertex_ai_live_passthrough.py test: move 81 legacy live tests in pass-through, spend, batches, audio, search, guardrails, image and ocr dirs offline (#45288) 2026-10-08 02:38:12 -07:00
test_vertex_passthrough_load_balancing.py fix(vertex_ai): authenticate Vertex AI pass-through requests once (#48942) 2026-11-07 00:25:51 -08:00
test_watsonx_proxy_route.py fix(watsonx): read pass-through credentials from use_in_pass_through deployments (#49462) 2026-10-31 11:53:25 -07:00