-
-
Notifications
You must be signed in to change notification settings - Fork 486
Incoming OCPP message validation
SteVe performs two types of validation on incoming OCPP messages:
-
OCPP protocol validation checks requirements defined directly by the OCPP specification, such as required fields, string lengths, and valid data types. A violation immediately stops processing, and SteVe sends a generic OCPP error response. We started doing these validations since version 3.11.0.
-
Business and semantic validation checks whether a technically valid message is logically consistent and safe to process. This is the subject of this page. We started doing these validations since version 3.12.0.
Business and semantic validation failures are classified as either soft or hard.
| Severity | Meaning | General behavior |
|---|---|---|
| Soft | Suspicious input that can still be processed | Log a warning and continue |
| Hard | Input that prevents safe normal processing | Log an error and apply request-specific failure handling |
Multiple validation errors from one request can be reported together. Soft errors do not stop processing unless the request also contains a hard error.
The source of truth is the implementation in CentralSystemService16_ServiceValidator, together with its caller, CentralSystemService16_Service.
Timestamp comparisons use an operational tolerance to accommodate clock drift and small differences in sampling time.
The default tolerance is five minutes. A timestamp exactly at the five-minute tolerance boundary is accepted.
| OCPP request | Validation condition | Severity | Processing outcome |
|---|---|---|---|
StatusNotification |
connectorId < 0 |
Hard | Log an error and return an empty StatusNotificationResponse. Do not persist the connector status, cancel reservations, or publish the status-update event. |
StatusNotification |
The optional timestamp is later than server time plus tolerance | Soft | Log a warning and continue normally. |
SecurityEventNotification |
Timestamp is later than server time plus tolerance | Soft | Log a warning and continue normally, including persistence of the security event. |
StartTransaction |
connectorId < 1 |
Hard | Log an error, but intentionally continue. Persist the transaction, publish the transaction-started event, and return a transaction ID. |
StartTransaction |
meterStart < 0 |
Hard | Log an error, but intentionally continue. Persist the transaction, publish the transaction-started event, and return a transaction ID. |
StartTransaction |
Timestamp is later than server time plus tolerance | Soft | Log a warning and continue normally. |
StopTransaction |
Referenced transaction cannot be found | Hard | Persist the stop in transaction_stop_failed; do not create a normal transaction stop or publish the transaction-ended event. Attached transaction data cannot be persisted without the transaction record. |
StopTransaction |
Transaction was already stopped by the station | Hard | Persist the stop in transaction_stop_failed, persist eligible attached meter data, and skip normal stop processing and event publication. |
StopTransaction |
Transaction start timestamp is after the stop timestamp | Hard | Persist the stop in transaction_stop_failed, persist eligible attached meter data, and skip normal stop processing and event publication. |
StopTransaction |
Stop timestamp is later than server time plus tolerance | Hard | Persist the stop in transaction_stop_failed, persist eligible attached meter data, and skip normal stop processing and event publication. |
StopTransaction |
meterStart > meterStop |
Hard | Persist the stop in transaction_stop_failed, persist eligible attached meter data, and skip normal stop processing and event publication. |
StopTransaction |
A non-empty stop idTag differs from the transaction's start idTag and the two tags are not related through parentIdTag (i.e. one is not the parent of the other, or they do not have the same parent) |
Hard | Persist the stop in transaction_stop_failed, persist eligible attached meter data, and skip normal stop processing and event publication. |
MeterValues with a transaction reference |
Referenced transaction cannot be found | Hard | Log an error, return an empty MeterValuesResponse, and do not persist the meter values. |
MeterValues with a transaction reference |
Referenced transaction was already stopped by the station | Hard | Log an error, return an empty MeterValuesResponse, and do not persist the meter values. |
MeterValues |
connectorId < 0 |
Hard | Log an error, return an empty MeterValuesResponse, and do not persist the meter values. |
MeterValues or StopTransaction.transactionData
|
A non-null meter value has no timestamp | Hard | Apply the hard-error processing behavior of the enclosing request. |
MeterValues or StopTransaction.transactionData
|
A non-empty collection contains no usable timestamp, for example because every entry is null
|
Hard | Apply the hard-error processing behavior of the enclosing request. |
MeterValues or StopTransaction.transactionData
|
At least one meter-value timestamp is later than server time plus tolerance | Soft | Log a warning and continue normally. |
StopTransaction.transactionData |
At least one meter-value timestamp is later than the stop timestamp plus tolerance | Soft | Log a warning and continue normally. |
Transaction-related MeterValues or StopTransaction.transactionData
|
At least one meter-value timestamp is earlier than the transaction start timestamp minus tolerance | Soft | Log a warning and continue normally. |
| Request | Behavior when a hard error occurs |
|---|---|
StatusNotification |
Stop processing and return an empty response |
MeterValues |
Stop processing and do not persist the values |
StartTransaction |
Continue because SteVe must return a transaction ID |
StopTransaction |
Store the attempted stop in transaction_stop_failed; do not create a normal stop or publish the transaction-ended event |