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]

fix(vertex_ai): skip non-dict property values in set_schema_property_ordering

mateo-berrid804b9d4fe47
diff --git a/basedpyright-code-budget.json b/basedpyright-code-budget.json
index 8634e9a5c32..d572a328926 100644
--- a/basedpyright-code-budget.json
+++ b/basedpyright-code-budget.json
@@ -1,9 +1,9 @@
{
"reportAny": {
- "limit": 16282
+ "limit": 15294
},
"reportArgumentType": {
- "limit": 2529
+ "limit": 2520
},
"reportAssignmentType": {
"limit": 319
@@ -24,7 +24,7 @@
"limit": 19
},
"reportExplicitAny": {
- "limit": 5062
+ "limit": 4639
},
"reportFunctionMemberAccess": {
"limit": 7
@@ -42,7 +42,7 @@
"limit": 12
},
"reportIndexIssue": {
- "limit": 30
+ "limit": 25
},
"reportInvalidTypeForm": {
"limit": 34
@@ -54,10 +54,10 @@
"limit": 0
},
"reportMissingParameterType": {
- "limit": 5642
+ "limit": 5626
},
"reportMissingTypeArgument": {
- "limit": 15404
+ "limit": 15383
},
"reportMissingTypeStubs": {
"limit": 40
@@ -105,19 +105,19 @@
"limit": 109
},
"reportUnknownMemberType": {
- "limit": 38621
+ "limit": 38521
},
"reportUnknownParameterType": {
- "limit": 19748
+ "limit": 19718
},
"reportUnknownVariableType": {
- "limit": 30210
+ "limit": 30129
},
"reportUnnecessaryCast": {
"limit": 117
},
"reportUnnecessaryComparison": {
- "limit": 696
+ "limit": 695
},
"reportUnnecessaryContains": {
"limit": 5
@@ -141,6 +141,6 @@
"limit": 543
},
"reportUnusedVariable": {
- "limit": 139
+ "limit": 138
}
}
diff --git a/litellm/llms/vertex_ai/common_utils.py b/litellm/llms/vertex_ai/common_utils.py
index 1de316835a1..a36c920dda0 100644
--- a/litellm/llms/vertex_ai/common_utils.py
+++ b/litellm/llms/vertex_ai/common_utils.py
@@ -724,8 +724,9 @@ def set_schema_property_ordering(schema: dict[str, object], depth: int = 0) -> d
# retain propertyOrdering as an escape hatch if user already specifies it
if "propertyOrdering" not in schema:
schema["propertyOrdering"] = [k for k, v in schema["properties"].items()]
- for k, v in schema["properties"].items():
- set_schema_property_ordering(v, depth + 1)
+ for v in schema["properties"].values():
+ if isinstance(v, dict):
+ set_schema_property_ordering(cast("dict[str, object]", v), depth + 1) # cast-ok: JSON Schema child
items: Final = schema.get("items")
if isinstance(items, dict):
set_schema_property_ordering(cast("dict[str, object]", items), depth + 1) # cast-ok: JSON Schema child
diff --git a/ruff-strict-budget.json b/ruff-strict-budget.json
index 35bedee08a9..f479764f269 100644
--- a/ruff-strict-budget.json
+++ b/ruff-strict-budget.json
@@ -1,21 +1,21 @@
{
"ANN001": {
- "limit": 2996
+ "limit": 2988
},
"ANN002": {
"limit": 71
},
"ANN003": {
- "limit": 823
+ "limit": 821
},
"ANN201": {
"limit": 2003
},
"ANN202": {
- "limit": 841
+ "limit": 839
},
"ANN204": {
- "limit": 698
+ "limit": 696
},
"ANN205": {
"limit": 112
@@ -24,7 +24,7 @@
"limit": 133
},
"ANN401": {
- "limit": 378
+ "limit": 240
},
"ASYNC230": {
"limit": 11
@@ -117,7 +117,7 @@
"limit": 1
},
"PERF102": {
- "limit": 23
+ "limit": 22
},
"PERF401": {
"limit": 12
@@ -168,7 +168,7 @@
"limit": 3
},
"RET504": {
- "limit": 173
+ "limit": 172
},
"RUF012": {
"limit": 239
@@ -198,7 +198,7 @@
"limit": 58
},
"SIM102": {
- "limit": 311
+ "limit": 309
},
"SIM103": {
"limit": 119
@@ -231,7 +231,7 @@
"limit": 5
},
"TID251": {
- "limit": 1092
+ "limit": 1080
},
"TRY002": {
"limit": 524
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 cc923f05831..d1d751989ea 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
@@ -195,6 +195,22 @@ def test_set_schema_property_ordering_with_excessive_nesting():
set_schema_property_ordering(schema)
+def test_set_schema_property_ordering_skips_non_dict_property_values():
+ """Non-dict property values must be skipped, not recursed into (they used to raise)."""
+ schema = {
+ "properties": {
+ "a": "hello",
+ "b": {"type": "string"},
+ "c": ["x"],
+ "d": "a string mentioning items",
+ }
+ }
+
+ result = set_schema_property_ordering(schema)
+
+ assert result["propertyOrdering"] == ["a", "b", "c", "d"]
+
+
def test_build_vertex_schema():
"""Test build_vertex_schema with a sample schema"""
from litellm.llms.vertex_ai.common_utils import _build_vertex_schema
diff --git a/type-discipline-budget.json b/type-discipline-budget.json
index 8c83bde8774..2518ff223ac 100644
--- a/type-discipline-budget.json
+++ b/type-discipline-budget.json
@@ -1,9 +1,9 @@
{
"LIT001": {
- "limit": 22604
+ "limit": 22554
},
"LIT002": {
- "limit": 26806
+ "limit": 26782
},
"LIT003": {
"limit": 269
@@ -27,10 +27,10 @@
"limit": 0
},
"LIT010": {
- "limit": 16528
+ "limit": 16510
},
"LIT011": {
- "limit": 5539
+ "limit": 5520
},
"LIT012": {
"limit": 4506