]> Piment Noir Git Repositories - e-mobility-charging-stations-simulator.git/commitdiff
fix(ocpp16): reject float values for integer configuration keys per spec §5.3
authorJérôme Benoit <jerome.benoit@sap.com>
Mon, 16 Mar 2026 00:20:36 +0000 (01:20 +0100)
committerJérôme Benoit <jerome.benoit@sap.com>
Mon, 16 Mar 2026 00:20:36 +0000 (01:20 +0100)
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.

src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts

index 6a188dfff9d7f46ed0a56906eb701b233cbae0dd..a530bc2780da772c26bfab0e3c1fbc6d82678585 100644 (file)
@@ -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
         }
       }