]> Piment Noir Git Repositories - e-mobility-charging-stations-simulator.git/commitdiff
fix(auth): log actual station OCPP version in RemoteAuthStrategy
authorJérôme Benoit <jerome.benoit@sap.com>
Fri, 20 Mar 2026 18:49:23 +0000 (19:49 +0100)
committerJérôme Benoit <jerome.benoit@sap.com>
Fri, 20 Mar 2026 18:49:23 +0000 (19:49 +0100)
Deduplicate adapter validation in initialize() to avoid logging the
same adapter twice for VERSION_20/VERSION_201 aliases. Add ocppVersion
to AuthConfiguration so strategies log the station's configured version
instead of internal map keys.

src/charging-station/ocpp/auth/services/OCPPAuthServiceImpl.ts
src/charging-station/ocpp/auth/strategies/RemoteAuthStrategy.ts
src/charging-station/ocpp/auth/types/AuthTypes.ts

index ac08d8bd73212b6c6273eac357d35997e3d80f04..776050a3b18ced5d9dc6198a54308a0b6195c109 100644 (file)
@@ -651,6 +651,7 @@ export class OCPPAuthServiceImpl implements OCPPAuthService {
       localAuthListEnabled: true,
       localPreAuthorize: false,
       maxCacheEntries: 1000,
+      ocppVersion: this.chargingStation.stationInfo?.ocppVersion,
       offlineAuthorizationEnabled: true,
       remoteAuthorization: true,
       unknownIdAuthorization: AuthorizationStatus.INVALID,
index c60a44d1a56734705f6cea67d94e3d99984814a3..82135f70401ed6f84b3e4a7720face08e1f2ac5c 100644 (file)
@@ -266,19 +266,27 @@ export class RemoteAuthStrategy implements AuthStrategy {
         logger.warn(`${moduleName}: No OCPP adapters provided`)
       }
 
-      // Validate adapter configurations
-      for (const [version, adapter] of this.adapters) {
+      const stationVersion = config.ocppVersion ?? 'unknown'
+
+      // Validate adapter configurations (deduplicate by instance to avoid
+      // validating the same adapter twice for VERSION_20 and VERSION_201)
+      const validatedAdapters = new Set<OCPPAuthAdapter>()
+      for (const [, adapter] of this.adapters) {
+        if (validatedAdapters.has(adapter)) {
+          continue
+        }
+        validatedAdapters.add(adapter)
         try {
           const isValid = adapter.validateConfiguration(config)
           if (!isValid) {
-            logger.warn(`${moduleName}: Invalid configuration for OCPP ${version}`)
+            logger.warn(`${moduleName}: Invalid configuration for OCPP ${stationVersion}`)
           } else {
-            logger.debug(`${moduleName}: OCPP ${version} adapter configured`)
+            logger.debug(`${moduleName}: OCPP ${stationVersion} adapter configured`)
           }
         } catch (error) {
           const errorMessage = getErrorMessage(error)
           logger.error(
-            `${moduleName}: Configuration validation failed for OCPP ${version}: ${errorMessage}`
+            `${moduleName}: Configuration validation failed for OCPP ${stationVersion}: ${errorMessage}`
           )
         }
       }
index 2f7d7bceaebea6718799af9f13454017391eb2ae..e71823e27cca542e357753982c3e80a074310f63 100644 (file)
@@ -137,6 +137,9 @@ export interface AuthConfiguration extends JsonObject {
   /** Maximum cache entries */
   maxCacheEntries?: number
 
+  /** OCPP protocol version configured on the charging station */
+  ocppVersion?: string
+
   /** Enable offline authorization */
   offlineAuthorizationEnabled: boolean