litellm/tests/unit/llms/vertex_ai
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
..
agent_engine fix(streaming): keep merged think tags balanced and split SSE lines only on CR/LF (#48755) 2026-10-28 17:00:29 -07:00
audio_transcription feat(vertex_ai): label Vertex requests with the caller's key, team, org, and project (#50732) 2026-11-14 00:39:01 -05:00
batches feat(vertex_ai): label Vertex requests with the caller's key, team, org, and project (#50732) 2026-11-14 00:39:01 -05:00
context_caching fix(gemini): parse tool call arguments with the shared helper (#50020) 2026-11-16 19:31:25 -08:00
count_tokens ci(unit): cut unit check time with cheaper per-test resets and fewer non-unit tests (#51864) 2026-11-14 15:41:30 -08:00
files fix(anthropic)!: send extra_body fields at the top level of the Messages request (#48373) 2026-11-20 06:52:56 -08:00
fine_tuning fix(managed_files): send provider file ids when creating a fine-tuning job from managed files (#46552) 2026-10-19 14:40:15 -07:00
fixtures
gemini fix(vertex_ai): fail Gemini malformed replies with no output so retries and fallbacks run (#53231) 2026-11-21 09:49:27 -08:00
gemini_embeddings fix(gemini): support explicit text in embedding inputs (#53135) 2026-11-20 11:05:11 -08:00
image_edit fix(gemini): return n images for image generations and edits when n > 1 (#52103) 2026-11-16 14:50:13 -08:00
image_generation fix(gemini): bill cached input tokens on image generation (#52572) 2026-11-18 13:04:39 -08:00
interactions feat(vertex_ai): label Vertex requests with the caller's key, team, org, and project (#50732) 2026-11-14 00:39:01 -05:00
multimodal_embeddings feat(vertex_ai): label Vertex requests with the caller's key, team, org, and project (#50732) 2026-11-14 00:39:01 -05:00
rag_engine
realtime fix(realtime)!: send the Gemini Live setup at the first content so session.update settings apply (#39864) 2026-10-30 01:31:39 -07:00
rerank feat(vertex_ai): label Vertex requests with the caller's key, team, org, and project (#50732) 2026-11-14 00:39:01 -05:00
text_to_speech fix(vertex_ai): honor vertex_location for the Cloud Text-to-Speech endpoint (#50255) 2026-11-06 00:03:17 -08:00
vertex_ai_partner_models feat(messages): serve vertex ai claude messages on rust only (#52314) 2026-11-19 21:15:10 +00:00
vertex_embeddings fix(logging): stop keeping a full response copy nobody reads (#52524) 2026-11-18 11:51:01 -08:00
vertex_gemma_models fix(streaming)!: send the include_usage chunk with an empty choices array (#47109) 2026-10-21 02:26:05 +00:00
videos feat(vertex_ai): label Vertex requests with the caller's key, team, org, and project (#50732) 2026-11-14 00:39:01 -05:00
__init__.py
google_genai_proxy_test_config.yaml
test_bge_embedding.py
test_bge_response_transformation.py
test_common_utils.py
test_gemini_batch_embeddings.py
test_gemini_empty_properties.py
test_gemini_header_forwarding.py
test_http_status_201.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_request_labels.py feat(vertex_ai): label Vertex requests with the caller's key, team, org, and project (#50732) 2026-11-14 00:39:01 -05:00
test_vertex.py feat(messages): serve vertex ai claude messages on rust only (#52314) 2026-11-19 21:15:10 +00:00
test_vertex_ai_batch_transformation.py
test_vertex_ai_common_utils.py fix(vertex-ai): send union-root tool schemas as parametersJsonSchema (#51835) 2026-11-14 17:29:37 -05:00
test_vertex_ai_non_gemini.py
test_vertex_ai_psc_endpoint_support.py
test_vertex_ai_search_vector_store_transformation.py
test_vertex_gemini_gcs_uri_mime.py fix: preserve media across Responses and Gemini conversions (#48484) 2026-10-27 18:07:10 -07:00
test_vertex_global_url_support.py
test_vertex_image_generation.py
test_vertex_llm_base.py feat(bedrock): derive STS session tags and session name from caller identity (#52978) 2026-11-19 17:11:09 -08:00
test_vertex_model_garden_openapi.py
test_vertex_passthrough_logging_handler.py