fix(model): remove conflicting default on CommodityTariff RandomizationType - #4375
Closed
lboue wants to merge 1 commit into
Closed
fix(model): remove conflicting default on CommodityTariff RandomizationType#4375lboue wants to merge 1 commit into
lboue wants to merge 1 commit into
Conversation
…onType DayEntryStruct.RandomizationType declared both conformance "[RNDM]" (only allowed when the Randomization feature is supported) and default: 0. Writing a dayEntries list entry that omits RandomizationType auto-filled it with that default before validating conformance, then rejected the very same fill: Conformance "[RNDM]": Matter does not allow you to set this attribute A bare (non-list) struct attribute with the identical field shape (e.g. CurrentDayEntry) did not trip this — the auto-fill-then-reject only happens along the list-of-struct write path (Endpoint.setStateOf -> supervisor.patch -> StructManager), not a plain state property assignment. Per the spec text for both RandomizationOffset and RandomizationType (Matter 1.6 Application Cluster Spec, cluster section 9.12.5.10.4-5, as transcribed in commodity-tariff.resource.ts): "If this field is not indicated, randomization shall use the value in the Default* attribute." Absence is spec-meaningful (fall back to the cluster's own DefaultRandomizationType), not "value is None" — RandomizationOffset already has no default in the model, matching that; RandomizationType's default: 0 was inconsistent with its sibling field and collapsed that fallback semantic even when Randomization was enabled, on top of causing the conformance crash when it wasn't. Root-caused and reported against Luligu/matterbridge#625 (their ElectricalUtilityMeter.addElectricalMeter()'s energyTariff option hits this exact path). Full crash log and analysis in the linked issue. Related issue: matter-js#4374 Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
4 tasks
Contributor
|
Tick the box to add this pull request to the merge queue (same as
|
Collaborator
|
nooo, we never change the model files directly! And in fact the default: "None" is basically defined by spec ... so have you more details like exact code to check that and verify? But the fix - if we change the default at all is a model override but this more looks like some other root cause. I close this PR and will check the issue later |
8 tasks
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.
Type of change
Description
CommodityTariff.DayEntryStruct.RandomizationTypedeclared both conformance"[RNDM]"(only allowedwhen the
Randomizationfeature is supported) anddefault: 0. Writing adayEntrieslist entry thatomits
RandomizationTypeauto-filled it with that default before validating conformance, then rejectedthe very same fill:
This only happens along the list-of-struct write path (
Endpoint.setStateOf→supervisor.patch→StructManager) — a plain state property assignment (agent.get(...).state.dayEntries = [...]) or abare, non-list struct attribute with the identical field shape (e.g.
CurrentDayEntry) don't trip it.Per the spec text for both
RandomizationOffsetandRandomizationType(Application ClusterSpecification § 9.12.5.10.4–5, as transcribed in
commodity-tariff.resource.ts): "If this field is notindicated, randomization shall use the value in the Default* attribute." Absence is spec-meaningful
(fall back to the cluster's own
DefaultRandomizationType), not "value isNone".RandomizationOffsetalready has no
defaultin the model, matching that —RandomizationType'sdefault: 0wasinconsistent with its sibling field, and collapsed that fallback semantic even when
Randomizationwasenabled, on top of causing the conformance crash when it wasn't.
Fix: remove the conflicting
default: 0.Backing evidence
(Log attached on #4374, from the real-world crash in a Matterbridge plugin. This PR also adds a
self-contained regression test —
CommodityTariffServerTest.ts— that reproduces the exact same errorvia
MockServerNode+Endpoint.setStateOf(), with and without the fix.)Checklist
npm testpasses — ran@matter/model's build,@matter/node's fulltest/behaviors/**suite (390/390, including the new regression test) and@matter/general's suite (1330/1330). Could not complete a full rootnpm testin this sandbox: the browser/web test step fails on a missing Playwright browser binary, unrelated to this change.npm run format-verifyandnpm run lintpass (both run at the repo root, not just on the touched files)