-
-
Notifications
You must be signed in to change notification settings - Fork 581
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Incorrect error raised when validation fails inside child object and unevaluatedProperties: false
is applied to the parent object
#1087
Comments
unevaluatedProperties: false
is applied to the parent object
I haven't really stared at your examples carefully, but this would seem already fixed in the prerelease, as both give what you listed as your expected result. Feel free to have a look? |
@Julian Yep, I guess I should have checked out the most recent prerelease before writing this issue. You're right that the prerelease fixes my problems. I'll close this issue. Thanks for the help! Do you know when the next full release will be made? |
There's at least one issue still blocking a beta release (and then a final one) -- that's #1061, so you could keep an eye on that one, I'm hoping to get it done in the next week but other things keep cropping up. |
Great, thanks @Julian. Also, thanks for the great package! I was able to pick it up and start using it very easily. |
Very glad to hear it! |
The Problem
If a schema sets
unevaluatedProperties: false
at the top level and contains an object, errors that occur while validating the properties of the inner object are incorrectly reported. If any error occurs within the object, that object is reported as "unevaluated". This obscures the real error.Examples
Incorrect type results in unevaluated parent object
For example, given the following schema:
The following will validate correctly:
However, the following will raise
ValidationError: Unevaluated properties are not allowed ('foo' was unexpected)
whenValidationError: 'string-should-be-number' is not of type 'number'
would be expected.Missing required property results in unevaluated parent object
The same kind of problem occurs if a required property is missing. For example using this schema:
to validate this json:
{ "foo": {} }
should raise
ValidationError: 'bar' is a required property
but actually raisesValidationError: Unevaluated properties are not allowed ('foo' was unexpected)
.Unevaluated property inside object results in unevaluated parent object
This is even true when the error is violation of
unevaluatedProperties: false
on the inner object. So, given:to validate this:
The expected error would indicate that
meh
is an unevaluated property. Instead, the error falls to indicating thatfoo
is unevaluated.Expected:
ValidationError: Unevaluated properties are not allowed ('meh' was unexpected)
Actual:
ValidationError: Unevaluated properties are not allowed ('foo' was unexpected)
What I've found
It appears that, when an error occurs inside of an object, that object does not get reported as having been evaluated when
find_evaluated_property_keys_by_schema
is called. The unevaluated properties error appears to take precedence over any other error that occurred inside the object.The text was updated successfully, but these errors were encountered: