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

Amend validation error raised #506

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Open

Conversation

drc38
Copy link
Contributor

@drc38 drc38 commented Nov 3, 2023

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.

@drc38 drc38 requested a review from OrangeTux as a code owner November 3, 2023 10:24
ocpp/messages.py Outdated
Comment on lines 223 to 225
except json.JSONDecodeError:
raise ValidationError(
f"Error in decoding JSON validation schema for action: {message.action}"
Copy link
Collaborator

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)

Copy link
Contributor Author

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

@Jared-Newell-Mobility
Copy link
Contributor

If possible could you please add to this PR an entry in ChangeLog.md?

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

Successfully merging this pull request may close these issues.

3 participants