mirror of
https://github.com/tiennm99/litellm.git
synced 2026-08-01 00:21:18 +00:00
Rebasing 2
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user