Skip to content
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

Add an equivalent to best_match() from jsonschema for oneOf and anyOf failures #72

Open
mtreinish opened this issue Nov 6, 2019 · 0 comments

Comments

@mtreinish
Copy link

In the jsonschema library there is a best_match() function to try and match the underlying error from a failure in the schema validation: https://python-jsonschema.readthedocs.io/en/stable/errors/#best-match-and-relevance

This is especially useful in schemas with oneOfs in the schema because when there is an error in the payload being verified it results in the oneOf failing because none of the fields match. Which isn't normally useful when there is an error in an otherwise valid subschema causing the failure.

I've been working with using fastjsonschema on a particularly bad example of a schema for this case published here: https://qiskit.org/schemas/qobj_schema.json that uses large oneOfs often nested and figuring out the cause of a validation error with fastjsonschema is very difficult because it's often a top level oneOf rule that fails and the rule definition is the entire contents under that oneOf (which can be quite large). So the error messages returned by the JsonSchemaException doesn't really help for debugging, nor do any of the other exception parameters. I've had to either use best_match() from jsonschema on failure or if I have a known working example just looking at it side by side with the failure. Both of which are less than ideal.

It would be great enhancement to add some way of debugging these scenarios to the library so we can get the speed benefits of this library without having to sacrifice ease of debugging.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants