Skip to content

[OCPP 1.6] setting JSON configuration to include schema validation#1782

Merged
james-ctc merged 2 commits intomainfrom
fix/price-text-json-decode
Feb 4, 2026
Merged

[OCPP 1.6] setting JSON configuration to include schema validation#1782
james-ctc merged 2 commits intomainfrom
fix/price-text-json-decode

Conversation

@james-ctc
Copy link
Member

Describe your changes

fix: OCPP 1.6 set could accept invalid values that would fail schema validation

Once an invalid value is allowed then EVerest won't start due to invalid configuration. This fix checks that the new value will pass schema validation before allowing the set to be actioned.

Issue ticket number and link

Checklist before requesting a review

  • I have performed a self-review of my code
  • I have made corresponding changes to the documentation
  • I read the contribution documentation and made sure that my changes meet its requirements

…validation

Once an invalid value is allowed then EVerest won't start due to invalid
configuration. This fix checks that the new value will pass schema
validation before allowing the set to be actioned.

Signed-off-by: James Chapman <james.chapman@pionix.de>
Pietfried
Pietfried previously approved these changes Feb 4, 2026
bool ChargePointConfiguration::validate(const std::string_view& schema_file, const json& object) {
fs::path schema_path = ocpp_main_path / "profile_schemas" / schema_file;
std::ifstream ifs(schema_path);
auto schema_json = json::parse(ifs);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be moved inside the try block to avoid issues in case the schema file doesn't exist

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

Signed-off-by: James Chapman <james.chapman@pionix.de>
@james-ctc james-ctc enabled auto-merge February 4, 2026 10:10
@james-ctc james-ctc added this pull request to the merge queue Feb 4, 2026
Merged via the queue into main with commit 3083285 Feb 4, 2026
11 of 12 checks passed
@james-ctc james-ctc deleted the fix/price-text-json-decode branch February 4, 2026 10:38
james-ctc added a commit that referenced this pull request Feb 4, 2026
fix: setting JSON configuration to include schema validation (#1782)

Moved validation function to base class and added checks to V2
device model storage (OCPP 1.6)

Additional tests to ensure that schema validation on set works
for both JSON and database implemantations.

Signed-off-by: James Chapman <james.chapman@pionix.de>
james-ctc added a commit that referenced this pull request Feb 4, 2026
fix: setting JSON configuration to include schema validation (#1782)

Moved validation function to base class and added checks to V2
device model storage (OCPP 1.6)

Additional tests to ensure that schema validation on set works
for both JSON and database implemantations.

Signed-off-by: James Chapman <james.chapman@pionix.de>
james-ctc added a commit that referenced this pull request Feb 5, 2026
fix: setting JSON configuration to include schema validation (#1782)

Moved validation function to base class and added checks to V2
device model storage (OCPP 1.6)

Additional tests to ensure that schema validation on set works
for both JSON and database implemantations.

Signed-off-by: James Chapman <james.chapman@pionix.de>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working OCPP

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants