-
Notifications
You must be signed in to change notification settings - Fork 327
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
Amend validation error raised #506
base: master
Are you sure you want to change the base?
Conversation
ocpp/messages.py
Outdated
except json.JSONDecodeError: | ||
raise ValidationError( | ||
f"Error in decoding JSON validation schema for action: {message.action}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only a json.JSONDecodeError
should be mapped to a ValidationError
. An OSError
means that no schema with a given name was found. That means user is using a action that doesn't exists. Therefore, a NotSupportedError
is applicable. See my comment here: #494 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With #494 a FileNotFoundError
should not be raised by the OSError
exception, as before it gets to this part of the code a NotSupportedError
will be raised by_raise_key_error
. So an OSError
should only be raised for one of these other reasons https://docs.python.org/3/library/exceptions.html#os-exceptions
If possible could you please add to this PR an entry in ChangeLog.md? |
@drc38 Should we take this up? |
Hi @jainmohit2001 as per discussion above these two errors should only be raised on edge cases if the validation has failed. Prior to this part of the code being executed a My view is it should be merged. |
With the incorporation of #494 an OSError should only be raised on edge cases eg if the json schema file is corrupt. NotImplementedError and NotSupportedError errors will be raised prior to the json validation occurring, taking care of when the schema doesn't exist.