Skip to content

[nrf noup] [west zap] Refinements and fixes to some edge cases#719

Merged
markaj-nordic merged 4 commits into
nrfconnect:masterfrom
markaj-nordic:west-zap-refinements
May 29, 2026
Merged

[nrf noup] [west zap] Refinements and fixes to some edge cases#719
markaj-nordic merged 4 commits into
nrfconnect:masterfrom
markaj-nordic:west-zap-refinements

Conversation

@markaj-nordic
Copy link
Copy Markdown
Contributor

@markaj-nordic markaj-nordic commented Apr 29, 2026

[nrf noup] [west zap-gui] Refine error handling

It turns out that the subprocess may return no output
if the Chromium cannot use sandbox due to the missing
permissions. Added a workaround that raises an exception
if the command execution output is empty, so that it
can be handled with the fix_sandbox_permissions() call.

Signed-off-by: Marcin Kajor marcin.kajor@nordicsemi.no

[nrf noup] [west zap-sync] Handle overwriting of the default zcl file

Fixed the handling of the case when the default
cluster definition file (zcl.json) is used as both
input and output to the command. Without the fix,
the script removes the zcl.json and exits, because
the removed file cannot be copied.

Signed-off-by: Marcin Kajor marcin.kajor@nordicsemi.no

[nrf noup] [west zap-append] Add fallback to the attribute name deduction

Some XML cluster definitions do not contain the dedicated
'name' entry in the attribute field, instead they just
add name of the cluster as a text to the attribute
definition. Added a fallback logic, so that such cases
are handled to avoid ending up with null attributes in
zcl.json file. This mimics the ZAP loader behavior.

Signed-off-by: Marcin Kajor marcin.kajor@nordicsemi.no

Testing

Tested manually when adding a custom cluster.

@markaj-nordic markaj-nordic requested a review from a team as a code owner April 29, 2026 19:54
@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Apr 29, 2026

CLA assistant check
All committers have signed the CLA.

…tion

Some XML cluster definitions do not contain the dedicated
'name' entry in the attribute field, instead they just
add name of the cluster as a text to the attribute
definition. Added a fallback logic, so that such cases
are handled to avoid ending up with null attributes in
zcl.json file. This mimics the ZAP loader behavior.

Signed-off-by: Marcin Kajor <marcin.kajor@nordicsemi.no>
Fixed the handling of the case when the default
cluster definition file (zcl.json) is used as both
input and output to the command. Without the fix,
the script removes the zcl.json and exits, because
the removed file cannot be copied.

Signed-off-by: Marcin Kajor <marcin.kajor@nordicsemi.no>
It turns out that the subprocess may return no output
if the Chromium cannot use sandbox due to the missing
permissions. Added a workaround that raises an exception
if the command execution output is empty, so that it
can be handled with the fix_sandbox_permissions() call.

Signed-off-by: Marcin Kajor <marcin.kajor@nordicsemi.no>
NordicBuilder added a commit to NordicBuilder/sdk-nrf that referenced this pull request Apr 29, 2026
Automatically created by action-manifest-pr GH action from PR:
nrfconnect/sdk-connectedhomeip#719

Signed-off-by: Nordic Builder <pylon@nordicsemi.no>
@ArekBalysNordic ArekBalysNordic requested a review from Copilot April 30, 2026 12:58
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR refines the west zap-* helper scripts to better handle a few edge cases around ZAP execution failures, zcl.json syncing, and custom-cluster XML parsing.

Changes:

  • Prevent zap-sync from deleting the SDK default zcl.json when the same path is passed as both input and output.
  • Add a workaround to trigger sandbox-permissions recovery when the ZAP subprocess produces no output.
  • Add fallback logic to deduce attribute names from XML when the name attribute is missing.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 6 comments.

File Description
scripts/west/zap_sync.py Avoids unlink/copy when -j points at the default zcl.json; adds empty-stdout sandbox workaround.
scripts/west/zap_gui.py Adds the same empty-stdout sandbox workaround to GUI launching.
scripts/west/zap_common.py Adjusts user guidance for “Unknown attribute” and changes stdout printing behavior.
scripts/west/zap_append.py Adds attribute-name fallback logic when parsing custom cluster XML.
Comments suppressed due to low confidence (1)

scripts/west/zap_append.py:69

  • get_attribute_name() returns None when it can’t infer a name, but add_custom_attributes_from_xml() still records and writes that value into attributeAccessInterfaceAttributes (which becomes null in JSON). If the goal is to avoid null attribute entries, skip attributes when the name can’t be deduced (or raise a clear error) instead of appending None.
        for attribute in cluster.findall('attribute'):
            attr_type = attribute.get('type')
            attr_name = get_attribute_name(attribute)

            if attr_type and attr_type not in types:
                attributes_with_missing_types.append({
                    'cluster': cluster_name,
                    'attribute': attr_name,
                    'type': attr_type
                })

Comment thread scripts/west/zap_sync.py Outdated
Comment thread scripts/west/zap_gui.py
Comment thread scripts/west/zap_append.py Outdated
Comment thread scripts/west/zap_append.py Outdated
Comment thread scripts/west/zap_common.py Outdated
Comment thread scripts/west/zap_sync.py
Copy link
Copy Markdown
Contributor

@kkasperczyk-no kkasperczyk-no left a comment

Choose a reason for hiding this comment

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

LGTM, worth to address the copilot comments and checking if it works on desk.

- Refined error handling
- Reduced the verbosity

Signed-off-by: Marcin Kajor <marcin.kajor@nordicsemi.no>
NordicBuilder added a commit to NordicBuilder/sdk-nrf that referenced this pull request May 28, 2026
Automatically created by action-manifest-pr GH action from PR:
nrfconnect/sdk-connectedhomeip#719

Signed-off-by: Nordic Builder <pylon@nordicsemi.no>
@markaj-nordic
Copy link
Copy Markdown
Contributor Author

LGTM, worth to address the copilot comments and checking if it works on desk.

The valid Copilot comments have been addressed.

markaj-nordic pushed a commit to NordicBuilder/sdk-nrf that referenced this pull request May 28, 2026
Automatically created by action-manifest-pr GH action from PR:
nrfconnect/sdk-connectedhomeip#719

Signed-off-by: Nordic Builder <pylon@nordicsemi.no>
markaj-nordic pushed a commit to NordicBuilder/sdk-nrf that referenced this pull request May 29, 2026
Automatically created by action-manifest-pr GH action from PR:
nrfconnect/sdk-connectedhomeip#719

Signed-off-by: Nordic Builder <pylon@nordicsemi.no>
markaj-nordic pushed a commit to NordicBuilder/sdk-nrf that referenced this pull request May 29, 2026
Automatically created by action-manifest-pr GH action from PR:
nrfconnect/sdk-connectedhomeip#719

Signed-off-by: Nordic Builder <pylon@nordicsemi.no>
@markaj-nordic markaj-nordic merged commit 494ce18 into nrfconnect:master May 29, 2026
12 checks passed
NordicBuilder added a commit to NordicBuilder/sdk-nrf that referenced this pull request May 29, 2026
Automatically created by action-manifest-pr GH action from PR:
nrfconnect/sdk-connectedhomeip#719

Signed-off-by: Nordic Builder <pylon@nordicsemi.no>
rlubos pushed a commit to nrfconnect/sdk-nrf that referenced this pull request Jun 3, 2026
Automatically created by action-manifest-pr GH action from PR:
nrfconnect/sdk-connectedhomeip#719

Signed-off-by: Nordic Builder <pylon@nordicsemi.no>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants