mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-08 03:08:45 +00:00
fix(vertex_ai): skip non-dict property values in set_schema_property_ordering
The typed rewrite made the properties recursion call .get on every child, so a malformed schema with a string or list property value raised AttributeError where it previously passed through untouched.
This commit is contained in:
parent
ed416a06cb
commit
d804b9d4fe
5 changed files with 43 additions and 26 deletions
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue