From: Jérôme Benoit Date: Mon, 16 Mar 2026 00:20:36 +0000 (+0100) Subject: fix(ocpp16): reject float values for integer configuration keys per spec §5.3 X-Git-Tag: ocpp-server@v3.1.1~29 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=8dc905b10509344362ee4a686653598a50662cba;p=e-mobility-charging-stations-simulator.git fix(ocpp16): reject float values for integer configuration keys per spec §5.3 Replace convertToInt (parseInt — silently truncates 3.7 to 3) with Number.isInteger check. The spec §9.1 defines these keys as Type: integer, and §5.3 requires Rejected for values that do not conform to the expected format. --- diff --git a/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts b/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts index 6a188dff..a530bc27 100644 --- a/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts +++ b/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts @@ -743,8 +743,8 @@ export class OCPP16IncomingRequestService extends OCPPIncomingRequestService { OCPP16StandardParametersKey.WebSocketPingInterval, ]) if (integerKeys.has(keyToChange.key as OCPP16StandardParametersKey)) { - const numValue = convertToInt(value) - if (isNaN(numValue) || numValue < 0) { + const numValue = Number(value) + if (!Number.isInteger(numValue) || numValue < 0) { return OCPP16Constants.OCPP_CONFIGURATION_RESPONSE_REJECTED } }