Use fieldId for event fields; keep loader backwards compatible#1688
Use fieldId for event fields; keep loader backwards compatible#1688dhchandw wants to merge 1 commit intoproject-chip:masterfrom
Conversation
- 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"/> |
There was a problem hiding this comment.
this looks redundant at first glance
There was a problem hiding this comment.
These are updated so it adheres to the updated schema
There was a problem hiding this comment.
I see, its a little awkward but everything you did looks correct based on the ask so ill approve
Summary of ChangesHello @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
🧠 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
Activity
Using Gemini Code AssistThe 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
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 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
|
| <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"/> |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
This is to adhere to the Matter naming, Alchemy uses the XSD file to generate the ZAP file. Look at #1683
There was a problem hiding this comment.
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
Codecov Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
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.
| lastFieldId = | ||
| rawFieldId == null ? defaultFieldId : parseInt(rawFieldId) |
There was a problem hiding this comment.
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.
| lastFieldId = | |
| rawFieldId == null ? defaultFieldId : parseInt(rawFieldId) | |
| lastFieldId = rawFieldId ? parseInt(rawFieldId) : defaultFieldId |
to match zcl.xsd (eventField requires fieldId).
XML using id still loads.