python-jsonschema / jsonschema

An implementation of the JSON Schema specification for Python
https://python-jsonschema.readthedocs.io
MIT License
4.52k stars 574 forks source link

Validation error messages changed after upgrading jsonschema version from 3.2.0 to 4.21.1 #1233

Closed saksham99del closed 4 months ago

saksham99del commented 4 months ago

I recently updated my jsonschema version from 3.2.0 to latest one 4.21.1.Since upgrading the version my error messages are changed and i am not able to fix it.

Example Json : { "example": { "key":"value"} } If i change the value of key to key1.I used to get the error message " "key" is a required property " in the earlier version and now after upgrading I am getting the message that prints whole block instead of the affected key like " "{ "key1":"value"}" doesn't fulfill the required schema".Is there any way to still get the old message back while still using the latest version.

Julian commented 4 months ago

" "{ "key1":"value"}" doesn't fulfill the required schema

I'm assuming you're paraphrasing as this isn't a message this library would produce.

No, and error messages are explicitly not part of jsonschema's API.

If this is for testing, you shouldn't test against messages.

Otherwise you might be interested in #1218

saksham99del commented 4 months ago

Apologies The exact message produced by Library is : " { 'key1':'value'} is not valid under any of the given schemas" and this change in message is applicable from version 4.8.0 .

tanvn commented 4 months ago

I think I have faced the same issue, the previous version provides more informative error messages.

saksham99del commented 4 months ago

How did you mitigate the issue?

tanvn commented 4 months ago

Ah I just did not upgrade to 4.21.1, we are just using 4.17.x (IIRC 4.18.x also works)