From 48dc43132bfdf607155ca26fe159e5bf7e0ae6db Mon Sep 17 00:00:00 2001 From: WaleedH <42546485+WaleedHU@users.noreply.github.com> Date: Sat, 22 Aug 2026 12:42:26 +0300 Subject: [PATCH] test(vertex_ai): cover depth guard and non-dict nodes in oneOf conversion --- .../vertex_ai/test_vertex_ai_common_utils.py | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/tests/test_litellm/llms/vertex_ai/test_vertex_ai_common_utils.py b/tests/test_litellm/llms/vertex_ai/test_vertex_ai_common_utils.py index 23cceab882f..335219e4ac6 100644 --- a/tests/test_litellm/llms/vertex_ai/test_vertex_ai_common_utils.py +++ b/tests/test_litellm/llms/vertex_ai/test_vertex_ai_common_utils.py @@ -144,6 +144,32 @@ def test_build_vertex_schema_preserves_oneof_unions(): } +def test_oneof_conversion_with_excessive_nesting(): + from litellm.llms.vertex_ai.common_utils import _convert_oneof_to_anyof + + schema = {"type": "object", "properties": {}} + current = schema + for _ in range(DEFAULT_MAX_RECURSE_DEPTH + 1): + current["properties"] = {"nested": {"oneOf": [{"type": "string"}], "properties": {}}} + current = current["properties"]["nested"] + + 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_oneof_to_anyof(schema) + + +def test_oneof_conversion_ignores_non_dict_nodes(): + from litellm.llms.vertex_ai.common_utils import _convert_oneof_to_anyof + + schema = {"type": "object", "properties": {"tags": {"type": "array", "items": "string"}}} + + _convert_oneof_to_anyof(schema) + + assert schema == {"type": "object", "properties": {"tags": {"type": "array", "items": "string"}}} + + def test_build_vertex_schema_converts_null_branch_inside_oneof(): from litellm.llms.vertex_ai.common_utils import _build_vertex_schema