From 95f0284dcd06f6511821a2016c74e8c5b4acb3ec Mon Sep 17 00:00:00 2001
From: yunhanw <yunhanw@google.com>
Date: Fri, 5 Nov 2021 13:38:56 -0700
Subject: [PATCH] Inject nodeId from subscribed path to path set by SetDirty

--SetDirty don't take the nodeId in clusterInfo, it just mark all interested
attribute dirty, when generated report, we need explicitly inject node
Id from subscribed path to interested dirty path, then
construct correct tlv representation.
---
 src/app/reporting/Engine.cpp | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/app/reporting/Engine.cpp b/src/app/reporting/Engine.cpp
index 546d9e93d239c0..e4d711e61b945e 100644
--- a/src/app/reporting/Engine.cpp
+++ b/src/app/reporting/Engine.cpp
@@ -124,7 +124,11 @@ CHIP_ERROR Engine::BuildSingleReportDataAttributeDataList(ReportDataMessage::Bui
             {
                 if (clusterInfo->IsAttributePathSupersetOf(*path))
                 {
-                    err = RetrieveClusterData(apReadHandler->GetFabricIndex(), attributeDataList, *path);
+                    // SetDirty injects path into GlobalDirtySet path that don't have the particular nodeId,
+                    // need to inject nodeId from subscribed path here.
+                    ClusterInfo dirtyPath = *path;
+                    dirtyPath.mNodeId     = clusterInfo->mNodeId;
+                    err                   = RetrieveClusterData(apReadHandler->GetFabricIndex(), attributeDataList, dirtyPath);
                 }
                 else if (path->IsAttributePathSupersetOf(*clusterInfo))
                 {