From: Jérôme Benoit Date: Sun, 21 Jan 2024 10:05:24 +0000 (+0100) Subject: fix: improve malformed OCPP message handling X-Git-Tag: v1.2.33~39 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=c3c8ae3fa3d6978dd97a29ee94b42cece3affb1e;p=e-mobility-charging-stations-simulator.git fix: improve malformed OCPP message handling Signed-off-by: Jérôme Benoit --- diff --git a/src/charging-station/ChargingStation.ts b/src/charging-station/ChargingStation.ts index 3f0069af..10b32dce 100644 --- a/src/charging-station/ChargingStation.ts +++ b/src/charging-station/ChargingStation.ts @@ -1947,11 +1947,14 @@ export class ChargingStation extends EventEmitter { ) } } catch (error) { + if (!Array.isArray(request)) { + logger.error(`${this.logPrefix()} Incoming message '${request}' parsing error:`, error) + return + } let commandName: IncomingRequestCommand | undefined let requestCommandName: RequestCommand | IncomingRequestCommand | undefined let errorCallback: ErrorCallback - // eslint-disable-next-line @typescript-eslint/no-non-null-assertion - const [, messageId] = request! + const [, messageId] = request switch (messageType) { case MessageType.CALL_MESSAGE: [, , commandName] = request as IncomingRequest