-
-
Notifications
You must be signed in to change notification settings - Fork 590
$dynamicRefs not evaluated on error #1068
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
Comments
Thanks for the report -- I'll have a look at your example more carefully (probably not until after the release, so few weeks). Just to be sure immediately though, have you seen the discussions on the spec repo about And any improvements in error message would likely have to come after there is some sort of more "native" way of supporting But regardless this is likely very good to file, so appreciated certainly, and I suspect there's definitely at least one thing that should be addressable (just like I said, unless you care to take a stab, it'll take a bit for me to even think about it given some other priorities). |
I might be missing something about how |
Which are errors 1 and 2, sorry? We do indeed get two errors here in my implementation:
|
I also get 2 errors. What I mean to say is that if I remove the |
Sorry, can you be more specific about which example? Here, leaving everything the same but removing the
|
Let me try again once I'm back at my keyboard. The crux of this report is skipping evaluation on error, not a suboptimal "best match". |
Got it -- yep feel free to follow up -- I should say we pass all the upstream tests, so if indeed we find one that's correct according to the spec but incorrectly fails then the first step will be adding a test to the official suite. Certainly not impossible that that's the case though. |
This issue was an attempt to reproduce another issue minimally, but at this point I can't see the forest for the trees, so let's close it. |
BTW, I managed to reproduce this (my complex case involved two schemas and Simple case: import jsonschema
schema = {
'properties': {
'foo': {
'type': 'object',
'required': ['bar'],
},
},
'unevaluatedProperties': False,
}
instance = {
'foo': {},
}
validator_cls = jsonschema.validators.validator_for(schema)
validator = validator_cls(schema)
for err in validator.iter_errors(instance):
print('-' * 80)
print(err) This is clearly documented in the docs, and overall not that surprising given One thing I realized is that strategically positioning {
'unevaluatedProperties': False, # <-- 'unevaluated property' is best error
'properties': {
'foo': {
'type': 'object',
'required': ['bar'],
},
},
'unevaluatedProperties': False, # <-- 'required' is best error
} |
Thanks for the follow up. The last bit on position probably reflects that at the minute they're considered equally important, but suggestions for improvements to the best match heuristics are always welcome! |
If there are validation errors, a
$dynamicRef
appears not to be followed and thus not evaluated.If such schema is set to disallow unevaluated properties, then validation would result in an unevaluated properties error in addition to the "culprit" error. In particular when using
jsonschema.validate
, the "best match" is the unevaluated property "error".Example
Actual Result
Expected Result
and if not for the missing
ham
property, thespam
property would've been evaluated by the "hovercraft" definition, and thus there'd be no errors.The text was updated successfully, but these errors were encountered: