@@ -290,30 +290,32 @@ CHIP_ERROR CodegenDataModel::WriteAttribute(const InteractionModel::WriteAttribu
290
290
}
291
291
292
292
const EmberAfAttributeMetadata ** attributeMetadata = std::get_if<const EmberAfAttributeMetadata *>(&metadata);
293
- if (attributeMetadata == nullptr )
294
- {
295
- // All the global attributes that we do not have metadata for are
296
- // read-only. Specifically only the following list-based attributes match the
297
- // "global attributes not in metadata" (see GlobalAttributes.h :: GlobalAttributesNotInMetadat):
298
- // - AttributeList
299
- // - EventList
300
- // - AcceptedCommands
301
- // - GeneratedCommands
302
- //
303
- // Given the above, UnsupportedWrite should be correct (attempt to write to a read-only list)
304
- return CHIP_IM_GLOBAL_STATUS (UnsupportedWrite);
305
- }
293
+
294
+ // All the global attributes that we do not have metadata for are
295
+ // read-only. Specifically only the following list-based attributes match the
296
+ // "global attributes not in metadata" (see GlobalAttributes.h :: GlobalAttributesNotInMetadat):
297
+ // - AttributeList
298
+ // - EventList
299
+ // - AcceptedCommands
300
+ // - GeneratedCommands
301
+ //
302
+ // Given the above, UnsupportedWrite should be correct (attempt to write to a read-only list)
303
+ bool isReadOnly = (attributeMetadata == nullptr ) || (*attributeMetadata)->IsReadOnly ();
306
304
307
305
// Internal is allowed to bypass timed writes and read-only.
308
306
if (!request.operationFlags .Has (InteractionModel::OperationFlags::kInternal ))
309
307
{
310
- VerifyOrReturnError (!(*attributeMetadata)-> IsReadOnly () , CHIP_IM_GLOBAL_STATUS (UnsupportedWrite));
308
+ VerifyOrReturnError (!isReadOnly , CHIP_IM_GLOBAL_STATUS (UnsupportedWrite));
311
309
312
310
VerifyOrReturnError (!(*attributeMetadata)->MustUseTimedWrite () ||
313
311
request.writeFlags .Has (InteractionModel::WriteFlags::kTimed ),
314
312
CHIP_IM_GLOBAL_STATUS (NeedsTimedInteraction));
315
313
}
316
314
315
+ // Extra check: internal requests can bypass the read only check, however global attributes
316
+ // have no underlying storage, so write still cannot be done
317
+ VerifyOrReturnError (attributeMetadata != nullptr , CHIP_IM_GLOBAL_STATUS (UnsupportedWrite));
318
+
317
319
if (request.path .mDataVersion .HasValue ())
318
320
{
319
321
std::optional<InteractionModel::ClusterInfo> clusterInfo = GetClusterInfo (request.path );
0 commit comments