EDDN icon indicating copy to clipboard operation
EDDN copied to clipboard

Investigate if we can improve schema Validation Error reporting

Open Athanasius opened this issue 3 years ago • 2 comments

We use the jsonschema module to validate messages against our schemas.

At least in the manner we currently utilise it some of the messages for failed validation aren't as useful as they could be.

e.g. if someone attempts to send data containing a key that the schema has tagged 'disallowed', then the reported error is something like:

"[<ValidationError: "{'type': ['array', 'boolean', 'integer', 'number', 'null', 'object', 'string']} is not allowed for 'BadVALUE'">]

which is citing the value of the disallowed key when it would be more useful to cite the name of the key.

Hopefully, certainly in whatever version is current for python 3.9+, we can improve on this. If needs be we can investigate any alternative modules for validation.

Athanasius avatar Jan 11 '22 12:01 Athanasius

https://python-jsonschema.readthedocs.io/en/stable/errors/

Specifically: https://python-jsonschema.readthedocs.io/en/stable/errors/#jsonschema.exceptions.ValidationError.json_path bit will help improve it.

Athanasius avatar Sep 02 '22 17:09 Athanasius

Looks like useful feedback to pass back to clients, certainly.

Tkael avatar Sep 04 '22 17:09 Tkael