fix(dc_measurements): constrain the Thermal Record's JSON schema - #351
Merged
Minipada merged 1 commit intoAug 17, 2026
Merged
Conversation
thermal.json only said "object of numbers", so an empty Record, a nameless zone key or a sub-absolute-zero temperature all passed validation. Zone type strings are the field names, so there is no fixed `required` list to write; draft-07's minProperties/propertyNames express the same invariants the plugin already holds. Collection logic and the emitted Record shape are unchanged. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BNt4fpZwLcgztWNjcLxAKf Signed-off-by: David Bensoussan <d.bensoussan@proton.me>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## jazzy #351 +/- ##
=======================================
Coverage 67.54% 67.54%
=======================================
Files 95 95
Lines 5884 5884
=======================================
Hits 3974 3974
Misses 1910 1910
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Minipada
deleted the
feature/300-thermal-measurement-emits-an-unvalidated
branch
September 2, 2026 12:45
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #300
thermal.jsondeclared atype: objectwithadditionalProperties: {type: number}andnothing else —
{}validated, and so did a Record whose only "zone" was keyed"". Everyother Measurement's schema says something about what it emits; this one didn't.
The shape stays; only the schema changed
Zone
typestrings are the field names (x86_pkg_temp,cpu-thermal, …), platform-specificand unknowable ahead of time, so there is no fixed
properties/requiredlist to write — whichis why the original schema punted. Draft-07 has the vocabulary for this case:
minProperties: 1— at least one zone entry. For a map-shaped Record the entry is thefield, so this is the "missing a required field" case.
collect()already publishes nothingrather than a content-free
{}when no zone can be read, so it can't fire on the plugin's ownoutput: an empty Thermal Record reaching a Destination means something went wrong upstream.
propertyNames: {minLength: 1}— a zone with an emptytypefile can't become a namelesskey (
readZone()already rejects one).additionalProperties: {type: number, minimum: -273.15}— degrees Celsius, above absolutezero, so a garbage
tempread is caught rather than shipped.base_path,zones, auto-discovery, the graceful-degradation contract and the emitted{"<zone type>": <celsius>}map are untouched. Withenable_validatoroff the schema is neverloaded (
setValidationSchema()is already guarded on the flag), so behaviour there is unchanged.Tests
3 → 8 in
test_measurement_thermal.cpp. AThermalSchemahelper loads the installedthermal.jsonviaament_index_cpp::get_package_share_directory()— the same file and the samejson_validatorMeasurement::validateJSON()uses, so the shipped artifact is what's exercised.AcceptsARepresentativeRecordRejectsARecordWithNoZoneEntry{}failsRejectsMalformedZoneEntriesPublishedRecordValidatesAgainstTheSchemaMeasurementServer, validator onPublishesTheSameRecordWithTheValidatorOffenable_validator: false, same RecordWorth knowing, since the first draft of the end-to-end test failed on it:
enrichMsg()runsvalidateJSON()first and only then addsname/nested/flattened/run_id/tags, so asubscriber never sees the Record the validator saw. The test strips those framework keys — and
that ordering is why the schema can constrain values this tightly without breaking enrichment.
Verification
No colcon/ROS 2 in the dev sandbox, so this was built and tested for real in the cached
localhost/dc-workspace:latestPodman image with the worktree bind-mounted over/root/ws/src/ros2_data_collection.colcon test --packages-select dc_measurements:163 tests, 0 failures (8/8 thermal). The test log's
INFO … schema:line confirms the newschema is what the running plugin loads, and that Jazzy's
nlohmann_json_schema_validatorimplements
propertyNames/minProperties— the one real unknown here.prekpasses on allchanged files.
doc/src/dc/measurements/thermal.mdcarries the new schema and a sentence on whyit's shaped this way rather than as a
requiredlist.🤖 Generated with Claude Code
https://claude.ai/code/session_01BNt4fpZwLcgztWNjcLxAKf