EDDN
EDDN copied to clipboard
Investigate if we can improve schema Validation Error reporting
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.
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.
Looks like useful feedback to pass back to clients, certainly.