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

Bug in parsing floats in Payloads that yields the failure of sending 5 Messages #555

Open
AlfredoNaef opened this issue Dec 22, 2023 · 3 comments
Labels
question Further information is requested stale

Comments

@AlfredoNaef
Copy link

Hello,

The messages NotifyChargingLimitRequest, NotifyMonitoringReportRequest, ReportChargingProfilesRequest, RequestStartTransactionRequest and SetChargingProfileRequest fail to be validated and hence to be sent. The bug happen when in all these messages payloads is present a float. Specifcally :

  • NotifyChargingLimitRequest is when you add the optional filed charging_schedule, that requires ChargingScheduleType, that requires ChargingSchedulePeriodType, that requires the field limit as a float.

  • NotifyMonitoringReportRequest is when you add the optional filed monitor, that requires MonitoringDataType, that requires VariableMonitoringType, that requires the field value as a float.

  • ReportChargingProfilesRequest is always present because of the field charging_profile that requires ChargingProfileType, that requires ChargingScheduleType, that requires ChargingSchedulePeriodType, that requires the field limit as a float.

  • RequestStartTransactionRequest is when you add the optional field charging_profile that requires ChargingProfileType, that requires ChargingScheduleType, that requires ChargingSchedulePeriodType, that requires the field limit as a float.

  • SetChargingProfileRequest is always present because of the field charging_profile that requires ChargingProfileType, that requires ChargingScheduleType, that requires ChargingSchedulePeriodType, that requires the field limit as a float.

Aftre reading the comment inside your code to my understanding the problem is due to the parser used to parse the floats in the payloads, that a default is float(). Indeed, you left a comment specifying that for some schemas should be used decimal.Decimal. However, as an user of your library I can only access your code up to the call method of your ChargePoint class and there is no possibility for me to sepcify the parser inside call - validate_payload - get_validator. Do you think that adding the possibility to specify the parse_float at the call method will fix the issue or is there another problem with the parsing of the floats?

@OrangeTux
Copy link
Contributor

OrangeTux commented Jan 15, 2024

Thanks for your elaborate report.

I'm curious why validation fails, though. The schemas for OCPP 1.6 limit the decimal points of a few number types to 1. It does so using the JSON Schema keyword multipleOf. See for example the subschema for ChargingSchedulePeriod.limit.

You noticed correctly that this library includes a custom encoder to serialize these floats. See for example here and here.

The schemas of OCPP 2.0.1 don't use the multipleOf JSON keyword. Therefore, I don't understand how you run into validation issues. Can you provide a code example shows the validation issue?

@Jared-Newell-Mobility
Copy link
Contributor

To confirm the types highlighted in the issue are floats in the library - changing to question

@Jared-Newell-Mobility Jared-Newell-Mobility added question Further information is requested and removed bug Something isn't working labels Feb 6, 2024
Copy link

github-actions bot commented Dec 9, 2024

This issue is stale because it has been open for 30 days with no activity.

@github-actions github-actions bot added the stale label Dec 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested stale
Development

No branches or pull requests

3 participants