Skip to content

The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]

Rebasing 2

Nicholas Grabar09daeac18851
diff --git a/tests/litellm/llms/vertex_ai/test_vertex_ai_common_utils.py b/tests/litellm/llms/vertex_ai/test_vertex_ai_common_utils.py
index 77fa0661977..5c2f70527c4 100644
--- a/tests/litellm/llms/vertex_ai/test_vertex_ai_common_utils.py
+++ b/tests/litellm/llms/vertex_ai/test_vertex_ai_common_utils.py
@@ -221,3 +221,25 @@ def test_nested_anyof_conversion():
}
}
assert schema == expected
+
+def test_anyof_with_excessive_nesting():
+ """Test conversion with excessive nesting > max levels +1 deep."""
+ # generate a schema with excessive nesting
+ schema = {"type": "object", "properties": {}}
+ current = schema
+ for _ in range(DEFAULT_MAX_RECURSE_DEPTH + 1):
+ current["properties"] = {
+ "nested": {
+ "anyOf": [
+ {"type": "string"},
+ {"type": "null"}
+ ],
+ "properties": {}
+ }
+ }
+ current = current["properties"]["nested"]
+
+
+ # running the conversion will raise an error
+ with pytest.raises(ValueError, match=f"Max depth of {DEFAULT_MAX_RECURSE_DEPTH} exceeded while processing schema. Please check the schema for excessive nesting."):
+ convert_anyof_null_to_nullable(schema)