Skip to content

Use fieldId for event fields; keep loader backwards compatible#1688

Open
dhchandw wants to merge 1 commit intoproject-chip:masterfrom
dhchandw:task/useFieldId
Open

Use fieldId for event fields; keep loader backwards compatible#1688
dhchandw wants to merge 1 commit intoproject-chip:masterfrom
dhchandw:task/useFieldId

Conversation

@dhchandw
Copy link
Collaborator

  • Rename event attribute from id to fieldId in all ZCL/Matter XML
    to match zcl.xsd (eventField requires fieldId).
  • In zcl-loader-silabs.js, read fieldId with fallback to id so existing
    XML using id still loads.

- Rename event <field> attribute from id to fieldId in all ZCL/Matter XML
  to match zcl.xsd (eventField requires fieldId).
- In zcl-loader-silabs.js, read fieldId with fallback to id so existing
  XML using id still loads.
<field id="3" name="ChangeType" type="ChangeTypeEnum"/>
<field id="4" name="LatestValue" type="AccessControlEntry" isNullable="true"/>
<field id="0xFE" name="AdminFabricIndex" type="fabric_idx"/>
<field fieldId="1" name="AdminNodeID" type="node_id" isNullable="true"/>
Copy link
Collaborator

Choose a reason for hiding this comment

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

this looks redundant at first glance

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

These are updated so it adheres to the updated schema

Copy link
Collaborator

Choose a reason for hiding this comment

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

I see, its a little awkward but everything you did looks correct based on the ask so ill approve

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @dhchandw, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request standardizes the naming convention for event field identifiers within ZCL/Matter XML definitions. The 'id' attribute has been uniformly replaced with 'fieldId' across a wide range of XML files to conform to the updated schema. A critical component of this change is the implementation of a backward compatibility mechanism in the ZCL loader, ensuring that older XML configurations remain functional without immediate modification.

Highlights

  • Schema Alignment: The 'id' attribute for event fields in ZCL/Matter XML definitions has been renamed to 'fieldId' to align with the 'zcl.xsd' schema, which now explicitly requires 'fieldId'.
  • Backward Compatibility: The ZCL loader ('zcl-loader-silabs.js') was updated to ensure backward compatibility, allowing existing XML files that still use the 'id' attribute to be loaded correctly by falling back to 'id' if 'fieldId' is not present.
  • Extensive XML Updates: Numerous ZCL/Matter XML files across test resources and built-in data models have been updated to reflect the new 'fieldId' attribute for event fields and struct members.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • src-electron/zcl/zcl-loader-silabs.js
    • Updated event field ID parsing logic to prioritize 'fieldId' and maintain backward compatibility with 'id'.
  • test/resource/meta/api_maturity.xml
    • Updated event field 'id' attributes to 'fieldId'.
  • test/resource/meta/test1.xml
    • Updated event field 'id' attributes to 'fieldId'.
  • test/resource/old-matter/access-control-cluster.xml
    • Updated event field 'id' attributes to 'fieldId'.
  • test/resource/old-matter/basic-information-cluster.xml
    • Updated event field 'id' attributes to 'fieldId'.
  • test/resource/old-matter/boolean-state-cluster.xml
    • Updated event field 'id' attributes to 'fieldId'.
  • test/resource/old-matter/bridged-actions-cluster.xml
    • Updated event field 'id' attributes to 'fieldId'.
  • test/resource/old-matter/bridged-device-basic.xml
    • Updated event field 'id' attributes to 'fieldId'.
  • test/resource/old-matter/chip-ota.xml
    • Updated event field 'id' attributes to 'fieldId'.
  • test/resource/old-matter/door-lock-cluster.xml
    • Updated event field 'id' attributes to 'fieldId'.
  • test/resource/old-matter/general-diagnostics-cluster.xml
    • Updated event field 'id' attributes to 'fieldId'.
  • test/resource/old-matter/power-source-cluster.xml
    • Updated event field 'id' attributes to 'fieldId'.
  • test/resource/old-matter/software-diagnostics-cluster.xml
    • Updated event field 'id' attributes to 'fieldId'.
  • test/resource/old-matter/switch-cluster.xml
    • Updated event field 'id' attributes to 'fieldId'.
  • test/resource/old-matter/test-cluster.xml
    • Updated event field 'id' attributes to 'fieldId'.
  • test/resource/old-matter/thread-network-diagnostics-cluster.xml
    • Updated event field 'id' attributes to 'fieldId'.
  • test/resource/old-matter/wifi-network-diagnostics-cluster.xml
    • Updated event field 'id' attributes to 'fieldId'.
  • zcl-builtin/matter/data-model/chip/access-control-cluster.xml
    • Updated event field 'id' attributes to 'fieldId'.
  • zcl-builtin/matter/data-model/chip/actions-cluster.xml
    • Updated event field 'id' attributes to 'fieldId'.
  • zcl-builtin/matter/data-model/chip/basic-information-cluster.xml
    • Updated event field 'id' attributes to 'fieldId'.
  • zcl-builtin/matter/data-model/chip/boolean-state-cluster.xml
    • Updated event field 'id' attributes to 'fieldId'.
  • zcl-builtin/matter/data-model/chip/bridged-device-basic-information.xml
    • Updated event field 'id' attributes to 'fieldId'.
  • zcl-builtin/matter/data-model/chip/chip-ota.xml
    • Updated event field 'id' attributes to 'fieldId'.
  • zcl-builtin/matter/data-model/chip/door-lock-cluster.xml
    • Updated event field 'id' attributes to 'fieldId'.
  • zcl-builtin/matter/data-model/chip/general-diagnostics-cluster.xml
    • Updated event field 'id' attributes to 'fieldId'.
  • zcl-builtin/matter/data-model/chip/power-source-cluster.xml
    • Updated event field 'id' attributes to 'fieldId'.
  • zcl-builtin/matter/data-model/chip/software-diagnostics-cluster.xml
    • Updated event field 'id' attributes to 'fieldId'.
  • zcl-builtin/matter/data-model/chip/switch-cluster.xml
    • Updated event field 'id' attributes to 'fieldId'.
  • zcl-builtin/matter/data-model/chip/test-cluster.xml
    • Updated event field 'id' attributes to 'fieldId'.
  • zcl-builtin/matter/data-model/chip/thread-network-diagnostics-cluster.xml
    • Updated event field 'id' attributes to 'fieldId'.
  • zcl-builtin/matter/data-model/chip/wifi-network-diagnostics-cluster.xml
    • Updated event field 'id' attributes to 'fieldId'.
  • zcl-builtin/matter/new-data-model/ACL-Cluster.xml
    • Updated 'id' attributes to 'fieldId' for struct and event fields.
  • zcl-builtin/matter/new-data-model/AccountLogin.xml
    • Updated 'id' attributes to 'fieldId' for command and event fields.
  • zcl-builtin/matter/new-data-model/AdminCommissioningCluster.xml
    • Updated 'id' attributes to 'fieldId' for command fields.
  • zcl-builtin/matter/new-data-model/AlarmBase.xml
    • Updated 'id' attributes to 'fieldId' for command and event fields.
  • zcl-builtin/matter/new-data-model/ApplicationBasic.xml
    • Updated 'id' attributes to 'fieldId' for struct members.
  • zcl-builtin/matter/new-data-model/ApplicationLauncher.xml
    • Updated 'id' attributes to 'fieldId' for struct and command fields.
  • zcl-builtin/matter/new-data-model/AudioOutput.xml
    • Updated 'id' attributes to 'fieldId' for struct and command fields.
  • zcl-builtin/matter/new-data-model/BasicInformationCluster.xml
    • Updated 'id' attributes to 'fieldId' for struct and event fields.
  • zcl-builtin/matter/new-data-model/Binding-Cluster.xml
    • Updated 'id' attributes to 'fieldId' for struct members.
  • zcl-builtin/matter/new-data-model/BooleanState.xml
    • Updated 'id' attributes to 'fieldId' for event fields.
  • zcl-builtin/matter/new-data-model/BooleanStateConfiguration.xml
    • Updated 'id' attributes to 'fieldId' for command and event fields.
  • zcl-builtin/matter/new-data-model/Channel.xml
    • Updated 'id' attributes to 'fieldId' for struct and command fields.
  • zcl-builtin/matter/new-data-model/ColorControl.xml
    • Updated 'id' attributes to 'fieldId' for command fields.
  • zcl-builtin/matter/new-data-model/ContentAppObserver.xml
    • Updated 'id' attributes to 'fieldId' for command fields.
  • zcl-builtin/matter/new-data-model/ContentControl.xml
    • Updated 'id' attributes to 'fieldId' for struct and command fields.
  • zcl-builtin/matter/new-data-model/ContentLauncher.xml
    • Updated 'id' attributes to 'fieldId' for struct and command fields.
  • zcl-builtin/matter/new-data-model/DemandResponseLoadControl.xml
    • Updated 'id' attributes to 'fieldId' for struct, command, and event fields.
  • zcl-builtin/matter/new-data-model/Descriptor-Cluster.xml
    • Updated 'id' attributes to 'fieldId' for struct members.
  • zcl-builtin/matter/new-data-model/DeviceEnergyManagement.xml
    • Updated 'id' attributes to 'fieldId' for struct and event fields.
  • zcl-builtin/matter/new-data-model/DiagnosticLogsCluster.xml
    • Updated 'id' attributes to 'fieldId' for command fields.
  • zcl-builtin/matter/new-data-model/DiagnosticsGeneral.xml
    • Updated 'id' attributes to 'fieldId' for struct, command, and event fields.
  • zcl-builtin/matter/new-data-model/DiagnosticsSoftware.xml
    • Updated 'id' attributes to 'fieldId' for struct and event fields.
  • zcl-builtin/matter/new-data-model/DiagnosticsThread.xml
    • Updated 'id' attributes to 'fieldId' for struct and event fields.
  • zcl-builtin/matter/new-data-model/DiagnosticsWiFi.xml
    • Updated 'id' attributes to 'fieldId' for event fields.
  • zcl-builtin/matter/new-data-model/DoorLock.xml
    • Updated 'id' attributes to 'fieldId' for struct, command, and event fields.
  • zcl-builtin/matter/new-data-model/ElectricalEnergyMeasurement.xml
    • Updated 'id' attributes to 'fieldId' for struct and event fields.
  • zcl-builtin/matter/new-data-model/ElectricalPowerMeasurement.xml
    • Updated 'id' attributes to 'fieldId' for struct and event fields.
  • zcl-builtin/matter/new-data-model/EnergyCalendar.xml
    • Updated 'id' attributes to 'fieldId' for struct members.
  • zcl-builtin/matter/new-data-model/EnergyEVSE.xml
    • Updated 'id' attributes to 'fieldId' for struct, command, and event fields.
  • zcl-builtin/matter/new-data-model/EnergyPreference.xml
    • Updated 'id' attributes to 'fieldId' for struct members.
  • zcl-builtin/matter/new-data-model/EnergyPrice.xml
    • Updated 'id' attributes to 'fieldId' for struct, command, and event fields.
  • zcl-builtin/matter/new-data-model/FanControl.xml
    • Updated 'id' attributes to 'fieldId' for command fields.
  • zcl-builtin/matter/new-data-model/GeneralCommissioningCluster.xml
    • Updated 'id' attributes to 'fieldId' for struct members.
  • zcl-builtin/matter/new-data-model/Group-Key-Management-Cluster.xml
    • Updated 'id' attributes to 'fieldId' for struct and command fields.
  • zcl-builtin/matter/new-data-model/Groups.xml
    • Updated 'id' attributes to 'fieldId' for command fields.
  • zcl-builtin/matter/new-data-model/ICDManagement.xml
    • Updated 'id' attributes to 'fieldId' for struct and command fields.
  • zcl-builtin/matter/new-data-model/Identify.xml
    • Updated 'id' attributes to 'fieldId' for command fields.
  • zcl-builtin/matter/new-data-model/KeypadInput.xml
    • Updated 'id' attributes to 'fieldId' for command fields.
  • zcl-builtin/matter/new-data-model/Label-Cluster-LabelCluster.xml
    • Updated 'id' attributes to 'fieldId' for struct members.
  • zcl-builtin/matter/new-data-model/LevelControl.xml
    • Updated 'id' attributes to 'fieldId' for command fields.
  • zcl-builtin/matter/new-data-model/MediaInput.xml
    • Updated 'id' attributes to 'fieldId' for struct and command fields.
  • zcl-builtin/matter/new-data-model/MediaPlayback.xml
    • Updated 'id' attributes to 'fieldId' for struct and command fields.
  • zcl-builtin/matter/new-data-model/Messages.xml
    • Updated 'id' attributes to 'fieldId' for struct, command, and event fields.
  • zcl-builtin/matter/new-data-model/MicrowaveOvenControl.xml
    • Updated 'id' attributes to 'fieldId' for command fields.
  • zcl-builtin/matter/new-data-model/ModeBase.xml
    • Updated 'id' attributes to 'fieldId' for struct and command fields.
  • zcl-builtin/matter/new-data-model/ModeSelect.xml
    • Updated 'id' attributes to 'fieldId' for struct and command fields.
  • zcl-builtin/matter/new-data-model/Mode_DeviceEnergyManagement.xml
    • Updated 'id' attributes to 'fieldId' for struct members.
  • zcl-builtin/matter/new-data-model/Mode_Dishwasher.xml
    • Updated 'id' attributes to 'fieldId' for struct members.
  • zcl-builtin/matter/new-data-model/Mode_LaundryWasher.xml
    • Updated 'id' attributes to 'fieldId' for struct members.
  • zcl-builtin/matter/new-data-model/Mode_RVCClean.xml
    • Updated 'id' attributes to 'fieldId' for struct members.
  • zcl-builtin/matter/new-data-model/Mode_RVCRun.xml
    • Updated 'id' attributes to 'fieldId' for struct members.
  • zcl-builtin/matter/new-data-model/Mode_Refrigerator.xml
    • Updated 'id' attributes to 'fieldId' for struct members.
  • zcl-builtin/matter/new-data-model/NetworkCommissioningCluster.xml
    • Updated 'id' attributes to 'fieldId' for struct and command fields.
  • zcl-builtin/matter/new-data-model/NetworkIdentityManagement.xml
    • Updated 'id' attributes to 'fieldId' for struct and command fields.
  • zcl-builtin/matter/new-data-model/OTAProvider.xml
    • Updated 'id' attributes to 'fieldId' for command fields.
  • zcl-builtin/matter/new-data-model/OTARequestor.xml
    • Updated 'id' attributes to 'fieldId' for struct, command, and event fields.
  • zcl-builtin/matter/new-data-model/OnOff.xml
    • Updated 'id' attributes to 'fieldId' for command fields.
  • zcl-builtin/matter/new-data-model/OperationalCredentialCluster.xml
    • Updated 'id' attributes to 'fieldId' for struct and command fields.
  • zcl-builtin/matter/new-data-model/OperationalState.xml
    • Updated 'id' attributes to 'fieldId' for struct, command, and event fields.
  • zcl-builtin/matter/new-data-model/PowerSourceCluster.xml
    • Updated 'id' attributes to 'fieldId' for command and event fields.
  • zcl-builtin/matter/new-data-model/ResourceMonitoring.xml
    • Updated 'id' attributes to 'fieldId' for struct members.
  • zcl-builtin/matter/new-data-model/Scenes.xml
    • Updated 'id' attributes to 'fieldId' for struct and command fields.
  • zcl-builtin/matter/new-data-model/SmokeCOAlarm.xml
    • Updated 'id' attributes to 'fieldId' for event fields.
  • zcl-builtin/matter/new-data-model/Switch.xml
    • Updated 'id' attributes to 'fieldId' for event fields.
  • zcl-builtin/matter/new-data-model/TargetNavigator.xml
    • Updated 'id' attributes to 'fieldId' for struct, command, and event fields.
  • zcl-builtin/matter/new-data-model/TemperatureControl.xml
    • Updated 'id' attributes to 'fieldId' for command fields.
  • zcl-builtin/matter/new-data-model/Thermostat.xml
    • Updated 'id' attributes to 'fieldId' for struct and command fields.
  • zcl-builtin/matter/new-data-model/ThreadBorderRouterDiagnostics.xml
    • Updated 'id' attributes to 'fieldId' for command fields.
  • zcl-builtin/matter/new-data-model/TimeSync.xml
    • Updated 'id' attributes to 'fieldId' for struct and event fields.
  • zcl-builtin/matter/new-data-model/ValveConfigurationControl.xml
    • Updated 'id' attributes to 'fieldId' for command and event fields.
  • zcl-builtin/matter/new-data-model/WaterHeaterManagement.xml
    • Updated 'id' attributes to 'fieldId' for command fields.
  • zcl-builtin/matter/new-data-model/WindowCovering.xml
    • Updated 'id' attributes to 'fieldId' for command fields.
  • zcl-builtin/shared/schema/zcl.xsd
    • Updated schema to enforce 'fieldId' as required for event fields and removed the optional 'id' attribute.
  • zcl-builtin/silabs/demo.xml
    • Updated event field 'id' attributes to 'fieldId'.
Activity
  • No human activity has been recorded on this pull request yet.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

<event side="server" code="0x00" name="StartUp" priority="critical" optional="false">
<description>The StartUp event SHALL be emitted by a Node as soon as reasonable after completing a boot or reboot process.</description>
<field id="0" name="SoftwareVersion" type="INT32U"/>
<field fieldId="0" name="SoftwareVersion" type="INT32U"/>
Copy link
Collaborator

Choose a reason for hiding this comment

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

Since this is already a element, is there a specific reason for renaming id to fieldId? It seems like id was already clearly referring to the field identifier.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is to adhere to the Matter naming, Alchemy uses the XSD file to generate the ZAP file. Look at #1683

Copy link
Collaborator

Choose a reason for hiding this comment

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

yeah, again, I see what you did. I don't really understand why it needs to be so explicit instead of obviously derived but everything you were asked to do looks correct so ill approve

@dhchandw dhchandw requested a review from paulr34 February 17, 2026 21:01
@dhchandw dhchandw linked an issue Feb 17, 2026 that may be closed by this pull request
@codecov-commenter
Copy link

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 75.23%. Comparing base (37ba4da) to head (beeee76).
⚠️ Report is 30 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1688      +/-   ##
==========================================
+ Coverage   66.75%   75.23%   +8.47%     
==========================================
  Files         200      202       +2     
  Lines       22799    23765     +966     
  Branches     5097     5439     +342     
==========================================
+ Hits        15220    17879    +2659     
+ Misses       7579     5886    -1693     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request updates event field attributes from id to fieldId across numerous XML files to align with the zcl.xsd schema. It also introduces backward compatibility in zcl-loader-silabs.js to handle both id and fieldId. The changes in the XML files are straightforward renames. The JavaScript change correctly prioritizes fieldId over id. However, I've found a potential issue in the JavaScript logic that could lead to NaN values when an id attribute is an empty string, which I've provided a suggestion to fix.

Comment on lines +591 to +592
lastFieldId =
rawFieldId == null ? defaultFieldId : parseInt(rawFieldId)
Copy link
Contributor

Choose a reason for hiding this comment

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

high

The new logic for determining lastFieldId introduces a potential issue. If field.$.fieldId is not present and field.$.id is an empty string (''), rawFieldId will be ''. The condition rawFieldId == null will be false, and parseInt(rawFieldId) will be called with an empty string, resulting in NaN. This NaN value for lastFieldId will propagate in subsequent iterations.

The previous logic (field.$.id ? parseInt(field.$.id) : defaultFieldId) correctly handled an empty string for id by treating it as falsy and using defaultFieldId. To maintain this behavior and make the code more robust, we should explicitly check for an empty string.

Suggested change
lastFieldId =
rawFieldId == null ? defaultFieldId : parseInt(rawFieldId)
lastFieldId = rawFieldId ? parseInt(rawFieldId) : defaultFieldId

Copy link
Collaborator

@paulr34 paulr34 left a comment

Choose a reason for hiding this comment

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

@dhchandw changes look fine. I am a little confused as to why the id cannot simply be derived from the tag but I guess that is a question for @hasty

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Event args in XML should use "fieldId" for its identifier

3 participants