Repository navigation
fix(charging-station): throw BaseError on invalid supervision URL and revert state on set failure - #2136
Conversation
… revert state on set failure Signed-off-by: reginaldalfret <[email protected]>
There was a problem hiding this comment.
The change is focused and mostly consistent with the existing error-handling pattern, but there is a type-level issue that should be addressed before merge. After fixing that, the state rollback behavior looks reasonable for the non-OCPP-configuration path.
PR Bot Information
Version: 1.31.69
- Agent Instructions:
- File Content Strategy: Full file content
- Correlation ID:
ada6c4c0-bff0-11f1-8fb9-5d16ced29fa3 - Event Trigger:
issue_comment.created - LLM:
gpt-5.5
The invalid-supervision-URL fix only covered the stationInfo branch of setSupervisionUrl and passed a cause option BaseError does not accept, so the file did not typecheck. Route every URL construction through a single parseSupervisionUrl helper that raises a BaseError naming the offending field, covering the template/config path, the OCPP-configuration key branch and the wsConnectionUrl getter, and add the regression tests the issue requires. Signed-off-by: Jérôme Benoit <[email protected]>
… the suite The getter guard added by the previous commit had no test: reverting it left the suite green. The three supervision URL tests also leaked a temp template directory each, because a station built with the default persistence writes its configuration after the synchronous afterEach ran cleanup. Move them into a dedicated ChargingStation-SupervisionUrl suite with an async teardown that drains the pending write, disable persistence on every station they build, add the missing getter regression, drop two inert creation options and pin the exact BaseError message and name. Name the charging station in the diagnostic and report the configured base URL instead of the derived one, so the error matches the issue acceptance criteria and no longer quotes a value the operator never configured. Signed-off-by: Jérôme Benoit <[email protected]>
|
Review follow-up in Fixed in this PR
Confirmed but out of scope, tracked separately
Verification: root |
Signed-off-by: Jérôme Benoit <[email protected]>
Signed-off-by: Jérôme Benoit <[email protected]>
There was a problem hiding this comment.
No new substantive issues found. The previous BaseError constructor issue has been resolved, and the added regression coverage addresses the relevant validation and rollback paths.
PR Bot Information
Version: 1.32.6
- LLM:
gpt-5.6-sol - Correlation ID:
68bce330-c28e-11f1-80c9-9a7cca6687a4 - Agent Instructions:
- Event Trigger:
issue_comment.created - File Content Strategy: Full file content
Summary
Fixes #2130.
BaseErrornaming the configured field and charging station, rather than a bareTypeError.stationInfo.supervisionUrlson validation failure. In the OCPP-key setter branch, store the parsed URL's normalizedhrefbefore applying credentials and retained options, so an accepted whitespace-bearing base does not fail later while building the worker update.Testing
Regression coverage is in
tests/charging-station/ChargingStation-SupervisionUrl.test.ts, including a real worker with persistent configuration. It verifies the consumer update URL, normalization, credentials (including an empty password), retained options, and unchanged memory and persisted bytes after a malformed update.ChargingStation-ResetIdentity.test.tsretains reset/reload coverage.Local verification: root
mise exec -- pnpm format,typecheck,lint,build, andtestpass (4,003 tests passed, 6 skipped). The two affected suites pass 13/13 on Node 24; URL validation also passes 6/6 on Node 22.14.0. A standalone real-worker smoke confirmed the normalized update URL and persisted key, and unchanged memory and file contents after rejection.The unrelated
ChangeConfigurationandperformanceStorage.uridefects remain tracked in #2141 and #2142.PR Checklist
Does this PR introduce a breaking change?