-
Notifications
You must be signed in to change notification settings - Fork 329
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
Fix validation of payloads containing floats #43
Labels
bug
Something isn't working
Comments
Hello @pagetable Nice catch! Here is a comment I found in our internal code base related to this issue: # These 3 schedules have fields of type floats. The JSON schema defines
# a certain precision for these fields of 1 decimal. A value of 21.4 is
# valid, whereas a value if 4.11 is not.
#
# The problem is that Python's internal representation of 21.4 might
# have more than 1 decimal. It might be 21.399999999999995. This would
# make the validation fail, although the payload is correct. This is a
# known issue with jsonschemas, see:
# https://github.com/Julian/jsonschema/issues/247
#
# This issue can be fixed by using a different parser for floats than
# the default one that is used.
#
# Both the schema and the payload must be parsed using the different
# parser for floats. I will implement it soon. |
OrangeTux
pushed a commit
that referenced
this issue
Nov 13, 2019
The validation of payloads using jsonschemas could fail when the payload contained a float. This problem is described in this issue: python-jsonschema/jsonschema#247 This commit implements a work around for this issue by changing the float parser for certain payloads from `float()` to `decimal.Decimal()`. Fixes: #43
OrangeTux
changed the title
What is the todo in validate_payload()
Fix validation of payloads containing floats
Nov 13, 2019
OrangeTux
pushed a commit
that referenced
this issue
Nov 19, 2019
The validation of payloads using jsonschemas could fail when the payload contained a float. This problem is described in this issue: python-jsonschema/jsonschema#247 This commit implements a work around for this issue by changing the float parser for certain payloads from `float()` to `decimal.Decimal()`. Fixes: #43
OrangeTux
pushed a commit
that referenced
this issue
Nov 19, 2019
The validation of payloads using jsonschemas could fail when the payload contained a float. This problem is described in this issue: python-jsonschema/jsonschema#247 This commit implements a work around for this issue by changing the float parser for certain payloads from `float()` to `decimal.Decimal()`. Fixes: #43
OrangeTux
added a commit
that referenced
this issue
Nov 21, 2019
The validation of payloads using jsonschemas could fail when the payload contained a float. This problem is described in this issue: python-jsonschema/jsonschema#247 This commit implements a work around for this issue by changing the float parser for certain payloads from `float()` to `decimal.Decimal()`. Fixes: #43
ajmirsky
pushed a commit
to ajmirsky/ocpp
that referenced
this issue
Nov 26, 2024
The validation of payloads using jsonschemas could fail when the payload contained a float. This problem is described in this issue: python-jsonschema/jsonschema#247 This commit implements a work around for this issue by changing the float parser for certain payloads from `float()` to `decimal.Decimal()`. Fixes: mobilityhouse#43
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
What are the todo and special actions in validate_payload() supposed to be? Are they to deal with the 'multipleof' problem of jsonschema check?
ocpp/ocpp/messages.py
Lines 118 to 124 in 75dd91f
Besides, I am not sure if it is proper to ask this question here, if not, please feel free to delete this issue.
Thank you.
The text was updated successfully, but these errors were encountered: