-
-
Notifications
You must be signed in to change notification settings - Fork 595
Closed
Labels
EnhancementSome new desired functionalitySome new desired functionalityError ReportingIssues related to clearer or more robust validation error reportingIssues related to clearer or more robust validation error reporting
Description
Applicators have poor best matched errors in some cases even when there is only a single schema within the applicator!
A reproducer is:
from jsonschema import Draft202012Validator as Validator, exceptions
instance = [12, 12]
for applicator in "anyOf", "oneOf":
# Should match {"items": {"const": 37}}
single = {applicator: [{"items": {"const": 37}}]}
error = exceptions.best_match(Validator(single).iter_errors(instance))
print(single, "\n\n", error)
# Should match {"items": {"const": 37}} due to type matching
multiple = {applicator: [{"type": "object"}, {"items": {"const": 37}}]}
error = exceptions.best_match(Validator(multiple).iter_errors(instance))
print(multiple, "\n\n", error)
# Should probably? match {"items": {"const": 37}} due to giving False low priority in any/oneOf
multiple_false = {applicator: [False, {"items": {"const": 37}}]}
error = exceptions.best_match(Validator(multiple_false).iter_errors(instance))
print(multiple_false, "\n\n", error)
where there seem to be 3 related but separate issues.
#1002 is likely related if not the same, but these examples are probably more minimized. We should recheck that issue when fixing.
Metadata
Metadata
Assignees
Labels
EnhancementSome new desired functionalitySome new desired functionalityError ReportingIssues related to clearer or more robust validation error reportingIssues related to clearer or more robust validation error reporting