Skip to content

Commit 1484260

Browse files
bzbarsky-applepull[bot]
authored andcommitted
Fix reporting of event path errors in MTRBaseDevice. (#26822)
Two main fixes here: * Don't lose the prceise error if we have one in OnEventData. * Use the right path key in our report dictionary for event errors. The path key problem has not been shipped in any releases before, so no backports needed. The other changes are just aligning the attribute and event cases on checking "is this a path we expected a report for?" before actually looking at the report we got.
1 parent f2275f9 commit 1484260

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/darwin/Framework/CHIP/MTRBaseDevice.mm

+7-2
Original file line numberDiff line numberDiff line change
@@ -819,12 +819,14 @@ void OnAttributeData(
819819
//
820820
VerifyOrDie(!aPath.IsListItemOperation());
821821

822-
VerifyOrExit(aStatus.IsSuccess(), err = aStatus.ToChipError());
823822
VerifyOrExit(
824823
std::find_if(mAttributePathParamsList, mAttributePathParamsList + mAttributePathParamsSize,
825824
[aPath](app::AttributePathParams & pathParam) -> bool { return pathParam.IsAttributePathSupersetOf(aPath); })
826825
!= mAttributePathParamsList + mAttributePathParamsSize,
827826
err = CHIP_ERROR_SCHEMA_MISMATCH);
827+
828+
VerifyOrExit(aStatus.IsSuccess(), err = aStatus.ToChipError());
829+
828830
VerifyOrExit(apData != nullptr, err = CHIP_ERROR_INVALID_ARGUMENT);
829831

830832
SuccessOrExit(err = app::DataModel::Decode(*apData, value));
@@ -852,6 +854,9 @@ void OnEventData(const EventHeader & aEventHeader, TLV::TLVReader * apData, cons
852854
})
853855
!= mEventPathParamsList + mEventPathParamsSize,
854856
err = CHIP_ERROR_SCHEMA_MISMATCH);
857+
858+
VerifyOrExit(apStatus == nullptr, err = apStatus->ToChipError());
859+
855860
VerifyOrExit(apData != nullptr, err = CHIP_ERROR_INVALID_ARGUMENT);
856861

857862
SuccessOrExit(err = app::DataModel::Decode(*apData, value));
@@ -1366,7 +1371,7 @@ - (void)subscribeToAttributePaths:(NSArray<MTRAttributeRequestPath *> * _Nullabl
13661371
ConcreteEventPath pathCopy(*eventPath);
13671372
dispatch_async(queue, ^{
13681373
reportHandler(@[ @ {
1369-
MTRAttributePathKey : [[MTREventPath alloc] initWithPath:pathCopy],
1374+
MTREventPathKey : [[MTREventPath alloc] initWithPath:pathCopy],
13701375
MTRErrorKey : [MTRError errorForCHIPErrorCode:error]
13711376
} ],
13721377
nil);

0 commit comments

Comments
 (0)