fix: harden composite input authoring

This commit is contained in:
lda
2026-08-14 12:01:44 +07:00 Verified
parent 4493b56ebe
commit 89e934e65b
13 changed files with 326 additions and 60 deletions
+15 -6
View File
@@ -160,12 +160,16 @@ def schema_location_is_explicit(
and part < len(current["prefixItems"])
):
return False
child = _array_item_schema(
current,
part,
label=label,
location=(*traversed, part),
)
try:
child = _array_item_schema(
current,
part,
label=label,
location=(*traversed, part),
)
except ValueError:
# Predicates remain total for invalid or unconstrained paths.
return False
else:
properties = current.get("properties")
if isinstance(properties, Mapping) and part in properties:
@@ -571,6 +575,11 @@ def _array_item_schema(
label: str,
location: Sequence[SchemaLocationPart],
) -> object:
if index < 0:
raise ValueError(
f"{label} array position {index} is negative at "
f"{_format_schema_location(location[:-1]) or label!r}"
)
schema_type = schema.get("type")
if schema_type is not None and schema_type != "array":
raise ValueError(