From b5849913285fed1973dc9b4bc6acd63a66279eb4 Mon Sep 17 00:00:00 2001 From: Nicholas Grabar Date: Fri, 28 Mar 2025 15:15:14 -0700 Subject: [PATCH] Rebasing 2 --- .../vertex_ai/test_vertex_ai_common_utils.py | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) 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 77fa066197..5c2f70527c 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)