From c718d9b5047f4beb5a2d0bbf101f0ba7bd74213a Mon Sep 17 00:00:00 2001 From: Chris Leishman Date: Mon, 16 Feb 2026 09:03:13 -0800 Subject: [PATCH] fix(data_model): silence spurious "Cluster cannot be NULL" error during dynamic endpoint init When using the esp_matter data model (CONFIG_ESP_MATTER_ENABLE_DATA_MODEL=y), attribute::get(endpoint_id, cluster_id, attribute_id) is called during endpoint registration via emberAfExternalAttributeReadCallback. If the cluster doesn't exist on the endpoint, the lookup returns NULL, which is then passed to the two-argument get(cluster_t*, attribute_id) overload that logs at error level. Add a NULL guard in the three-argument overload to return nullptr early, consistent with how command::get(endpoint_id, cluster_id, command_id) already handles this case. Fixes #1692 --- components/esp_matter/data_model/esp_matter_data_model.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/components/esp_matter/data_model/esp_matter_data_model.cpp b/components/esp_matter/data_model/esp_matter_data_model.cpp index 80cc0fb17..e083e3046 100644 --- a/components/esp_matter/data_model/esp_matter_data_model.cpp +++ b/components/esp_matter/data_model/esp_matter_data_model.cpp @@ -222,7 +222,7 @@ static void report_parts_list_change_internal(endpoint_t *endpoint) parent_endpoint_id = endpoint::get_parent_endpoint_id(endpoint::get(parent_endpoint_id)); } MatterReportingAttributeChangeCallback(/* endpoint = */ 0, chip::app::Clusters::Descriptor::Id, - chip::app::Clusters::Descriptor::Attributes::PartsList::Id); + chip::app::Clusters::Descriptor::Attributes::PartsList::Id); } esp_err_t disable(endpoint_t *endpoint) @@ -696,6 +696,9 @@ attribute_t *get(cluster_t *cluster, uint32_t attribute_id) attribute_t *get(uint16_t endpoint_id, uint32_t cluster_id, uint32_t attribute_id) { cluster_t *cluster = cluster::get(endpoint_id, cluster_id); + if (!cluster) { + return nullptr; + } return get(cluster, attribute_id); }