fix: add sanity check in ATG on connector id
authorJérôme Benoit <jerome.benoit@piment-noir.org>
Fri, 7 Jun 2024 19:43:20 +0000 (21:43 +0200)
committerJérôme Benoit <jerome.benoit@piment-noir.org>
Fri, 7 Jun 2024 19:43:20 +0000 (21:43 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@piment-noir.org>
src/charging-station/AutomaticTransactionGenerator.ts

index 83cf259a81f88e55dbc9b3e2f080497e358bd758..0eb47381876d833aef74796f6471a8af4bcb8c35 100644 (file)
@@ -408,6 +408,10 @@ export class AutomaticTransactionGenerator {
 
   private getConnectorStatus (connectorId: number): Status {
     const statusIndex = connectorId - 1
+    if (statusIndex < 0) {
+      logger.error(`${this.logPrefix(connectorId)} invalid connector id`)
+      throw new BaseError(`Invalid connector id ${connectorId}`)
+    }
     let connectorStatus: Status | undefined
     if (this.chargingStation.getAutomaticTransactionGeneratorStatuses()?.[statusIndex] != null) {
       connectorStatus = clone<Status>(