litellm/tests/unit/llms/vertex_ai
zoveki 89e0f3b771
fix(vertex_ai): stop a json_schema row failing the plain rows in its batch file (#51790)
* fix(vertex_ai): stop a json_schema row failing the plain rows in its batch file

Vertex loads a batch file into one BigQuery table, so each row's generationConfig
gains a null for every key another row sets. response_json_schema is a
google.protobuf.Value, so its null counts as set and every plain row with a
generationConfig of its own fails with "response_mime_type must be set".

Proto JSON takes both spellings of the field, so a row carrying a schema now uses
generation_config, which no other row shares. The request Vertex parses is the
same as before.

* fix(vertex_ai): inline json_schema $defs in Gemini batch rows

Vertex loads a batch file into BigQuery, whose column names cannot hold $, so one $defs key failed the whole batch. Schema rows now inline their refs through the shared defs helper. Also pins that the renamed row keeps every other key of the plain row

* fix(vertex_ai): drop or refuse json_schema $ keys in Gemini batch rows

BigQuery column names cannot hold $, so a $schema, $comment, recursive $ref or $-named property still failed the whole Vertex batch. Annotation keywords now drop under drop_params, else the upload answers 400 naming them, and keys that cannot be dropped always answer 400

defs_unpacked now merges $defs with definitions, and unpack_defs reuses the parent scope when a node adds no defs, so memory stays flat on large schemas

* fix(vertex_ai): keep json_schema literals and ref siblings in Gemini batch rows

defs_unpacked now lets $defs win when both blocks name the same def, which is what Anthropic requests got before, and it keeps the keys next to a $ref (a field's description) over the inlined target, like the OpenAI SDK does

The batch walk now runs top down, so const, default, enum, and example values pass through whole. A $ key inside one of them answers 400 at upload instead of being dropped, since dropping it would change the value the model must return

A $ref that is not #/$defs/<name> or #/definitions/<name>, such as a JSON pointer or an external URL, answers 400 at upload instead of resolving to a local def with the same last segment

* fix(vertex_ai): keep ref target constraints and keyword-named properties in Gemini batch rows

* fix(vertex_ai): add a required next to a json_schema ref to its target's in Gemini batch rows

* fix(vertex_ai): refuse json_schema keys a Gemini batch row would lose when a ref is inlined

Keys next to a $ref other than annotations and required answer 400, or drop under drop_params, and a $ref inside a literal value answers 400 before inlining. The inlining budget counts the kept annotations, a sibling required merges through a set lookup, and only the Vertex batch path keeps ref siblings, so Anthropic output schemas inline as before

* fix(prompt_templates): keep the 400 for a $ref to a def that is not an object

A $ref whose target is a boolean, number, string or list schema raised a
TypeError the proxy answers with a 500, or inlined the value, after the defs
merge skipped dict copies. It again takes the merge, which answers 400 as before

* perf(prompt_templates): stack nested $defs scopes instead of copying every outer def

A node or ref target with its own $defs used to copy every def above it, so a schema whose properties each add a def held one full copy per property. Each scope is now a tuple of the local defs and the enclosing scopes, looked up innermost first, which keeps the inlined output the same and the peak memory flat

* fix(vertex_ai): honor a Responses batch row's own drop_params when cleaning its json_schema

The Responses-to-Chat bridge leaves drop_params out of the chat body, so a /v1/responses row that set it still got the BigQuery '$' key refusal. The row's original body now supplies the flag

* fix(prompt_templates): resolve a definitions ref to its own block when $defs defines the same name differently

* fix(prompt_templates): track a definitions ref by its own block when checking for ref cycles

A $defs entry that refs the definitions entry of the same name was read as a cycle, because the cycle check keyed on the bare name. It now keys on the block the ref resolved to

---------

Co-authored-by: mateo-berri <277851410+mateo-berri@users.noreply.github.com>
2026-11-18 21:00:02 -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(vertex_ai): stop a json_schema row failing the plain rows in its batch file (#51790) 2026-11-18 21:00:02 -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 test: migrate tests/llm_translation into unit, integration and e2e tiers (#45759) 2026-10-11 07:58:53 +00:00
gemini fix(gemini): drop logprobs on every model Google refuses them for (#52700) 2026-11-19 00:54:19 +00:00
gemini_embeddings fix(vertex_ai): send document_ocr, audio_track_extraction and auto_truncate on Gemini embeddings (#51686) 2026-11-13 12:10:13 -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 fix(vertex_ai): keep legacy bucket_name in credential resolution and add GCS_BATCH_BUCKET_NAME env var (#42803) 2026-09-25 15:32:21 -07:00
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 fix(vertex_ai): resolve correct default max_tokens for versioned claude ids (#40376) 2026-11-14 17:36:51 -05: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 test: migrate legacy provider tests to tests/unit (wave 2, phase 13) 2026-09-20 14:18:49 +00:00
google_genai_proxy_test_config.yaml test: move whole-unit legacy test files into tests/unit and delete dead skips (#44807) 2026-10-07 05:02:28 +00:00
test_bge_embedding.py test: move tests/test_litellm/llms into tests/unit/llms (#43191) 2026-09-25 12:43:23 -07:00
test_bge_response_transformation.py refactor(llms): expose public names for private provider helpers (#45037) 2026-10-07 08:49:25 -07:00
test_common_utils.py refactor(llms): expose public names for private provider helpers (#45037) 2026-10-07 08:49:25 -07:00
test_gemini_batch_embeddings.py feat(gemini): accept file content blocks with video_metadata on multimodal embeddings (#45305) 2026-10-08 13:20:03 -07:00
test_gemini_empty_properties.py test: move tests/test_litellm/llms into tests/unit/llms (#43191) 2026-09-25 12:43:23 -07:00
test_gemini_header_forwarding.py test: move tests/test_litellm/llms into tests/unit/llms (#43191) 2026-09-25 12:43:23 -07:00
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 refactor(prompt_templates): move JSON schema helpers out of common_utils into json_schema_utils (#50241) 2026-11-05 17:25:53 -08:00
test_vertex_ai_batch_transformation.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_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 fix(vertex): report an unreadable credentials file as a read failure (#40173) 2026-10-15 02:03:56 -07:00
test_vertex_ai_psc_endpoint_support.py test: move tests/test_litellm/llms into tests/unit/llms (#43191) 2026-09-25 12:43:23 -07:00
test_vertex_ai_search_vector_store_transformation.py test: migrate legacy unit dirs and unrun folders into tests/unit, tests/integration and tests/e2e (#45940) 2026-10-11 06:24:57 -07:00
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 refactor(llms): expose public names for private provider helpers (#45037) 2026-10-07 08:49:25 -07:00
test_vertex_image_generation.py test: move tests/test_litellm/llms into tests/unit/llms (#43191) 2026-09-25 12:43:23 -07:00
test_vertex_llm_base.py fix(vertex_ai): reuse one Google token across RAG Engine searches and cold bursts (#51239) 2026-11-14 03:12:09 -05:00
test_vertex_model_garden_openapi.py test: move tests/test_litellm/llms into tests/unit/llms (#43191) 2026-09-25 12:43:23 -07:00
test_vertex_passthrough_logging_handler.py test: move tests/test_litellm/llms into tests/unit/llms (#43191) 2026-09-25 12:43:23 -07:00