Zap regen (#26911)

* Zap regen

* Undo undesired file change
diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRAttributeTLVValueDecoder.mm b/src/darwin/Framework/CHIP/zap-generated/MTRAttributeTLVValueDecoder.mm
index 5ca0aa2..2a8bcb7 100644
--- a/src/darwin/Framework/CHIP/zap-generated/MTRAttributeTLVValueDecoder.mm
+++ b/src/darwin/Framework/CHIP/zap-generated/MTRAttributeTLVValueDecoder.mm
@@ -10092,9 +10092,12 @@
                 while (iter_1.Next()) {
                     auto & entry_1 = iter_1.GetValue();
                     NSString * newElement_1;
-                    newElement_1 = [[NSString alloc] initWithBytes:entry_1.data()
-                                                            length:entry_1.size()
-                                                          encoding:NSUTF8StringEncoding];
+                    newElement_1 = AsString(entry_1);
+                    if (newElement_1 == nil) {
+                        CHIP_ERROR err = CHIP_ERROR_INVALID_ARGUMENT;
+                        *aError = err;
+                        return nil;
+                    }
                     [array_1 addObject:newElement_1];
                 }
                 CHIP_ERROR err = iter_1.GetStatus();
@@ -10153,9 +10156,12 @@
                 MTROperationalStateClusterOperationalStateStruct * newElement_0;
                 newElement_0 = [MTROperationalStateClusterOperationalStateStruct new];
                 newElement_0.operationalStateID = [NSNumber numberWithUnsignedChar:chip::to_underlying(entry_0.operationalStateID)];
-                newElement_0.operationalStateLabel = [[NSString alloc] initWithBytes:entry_0.operationalStateLabel.data()
-                                                                              length:entry_0.operationalStateLabel.size()
-                                                                            encoding:NSUTF8StringEncoding];
+                newElement_0.operationalStateLabel = AsString(entry_0.operationalStateLabel);
+                if (newElement_0.operationalStateLabel == nil) {
+                    CHIP_ERROR err = CHIP_ERROR_INVALID_ARGUMENT;
+                    *aError = err;
+                    return nil;
+                }
                 [array_0 addObject:newElement_0];
             }
             CHIP_ERROR err = iter_0.GetStatus();
@@ -10177,9 +10183,12 @@
         MTROperationalStateClusterOperationalStateStruct * _Nonnull value;
         value = [MTROperationalStateClusterOperationalStateStruct new];
         value.operationalStateID = [NSNumber numberWithUnsignedChar:chip::to_underlying(cppValue.operationalStateID)];
-        value.operationalStateLabel = [[NSString alloc] initWithBytes:cppValue.operationalStateLabel.data()
-                                                               length:cppValue.operationalStateLabel.size()
-                                                             encoding:NSUTF8StringEncoding];
+        value.operationalStateLabel = AsString(cppValue.operationalStateLabel);
+        if (value.operationalStateLabel == nil) {
+            CHIP_ERROR err = CHIP_ERROR_INVALID_ARGUMENT;
+            *aError = err;
+            return nil;
+        }
         return value;
     }
     case Attributes::OperationalError::Id: {
@@ -10195,14 +10204,20 @@
         if (cppValue.errorStateLabel.IsNull()) {
             value.errorStateLabel = nil;
         } else {
-            value.errorStateLabel = [[NSString alloc] initWithBytes:cppValue.errorStateLabel.Value().data()
-                                                             length:cppValue.errorStateLabel.Value().size()
-                                                           encoding:NSUTF8StringEncoding];
+            value.errorStateLabel = AsString(cppValue.errorStateLabel.Value());
+            if (value.errorStateLabel == nil) {
+                CHIP_ERROR err = CHIP_ERROR_INVALID_ARGUMENT;
+                *aError = err;
+                return nil;
+            }
         }
         if (cppValue.errorStateDetails.HasValue()) {
-            value.errorStateDetails = [[NSString alloc] initWithBytes:cppValue.errorStateDetails.Value().data()
-                                                               length:cppValue.errorStateDetails.Value().size()
-                                                             encoding:NSUTF8StringEncoding];
+            value.errorStateDetails = AsString(cppValue.errorStateDetails.Value());
+            if (value.errorStateDetails == nil) {
+                CHIP_ERROR err = CHIP_ERROR_INVALID_ARGUMENT;
+                *aError = err;
+                return nil;
+            }
         } else {
             value.errorStateDetails = nil;
         }
diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRCallbackBridge.mm b/src/darwin/Framework/CHIP/zap-generated/MTRCallbackBridge.mm
index f19e6f9..228f624 100644
--- a/src/darwin/Framework/CHIP/zap-generated/MTRCallbackBridge.mm
+++ b/src/darwin/Framework/CHIP/zap-generated/MTRCallbackBridge.mm
@@ -8941,7 +8941,12 @@
             while (iter_1.Next()) {
                 auto & entry_1 = iter_1.GetValue();
                 NSString * newElement_1;
-                newElement_1 = [[NSString alloc] initWithBytes:entry_1.data() length:entry_1.size() encoding:NSUTF8StringEncoding];
+                newElement_1 = AsString(entry_1);
+                if (newElement_1 == nil) {
+                    CHIP_ERROR err = CHIP_ERROR_INVALID_ARGUMENT;
+                    OnFailureFn(context, err);
+                    return;
+                }
                 [array_1 addObject:newElement_1];
             }
             CHIP_ERROR err = iter_1.GetStatus();
@@ -8983,9 +8988,12 @@
             MTROperationalStateClusterOperationalStateStruct * newElement_0;
             newElement_0 = [MTROperationalStateClusterOperationalStateStruct new];
             newElement_0.operationalStateID = [NSNumber numberWithUnsignedChar:chip::to_underlying(entry_0.operationalStateID)];
-            newElement_0.operationalStateLabel = [[NSString alloc] initWithBytes:entry_0.operationalStateLabel.data()
-                                                                          length:entry_0.operationalStateLabel.size()
-                                                                        encoding:NSUTF8StringEncoding];
+            newElement_0.operationalStateLabel = AsString(entry_0.operationalStateLabel);
+            if (newElement_0.operationalStateLabel == nil) {
+                CHIP_ERROR err = CHIP_ERROR_INVALID_ARGUMENT;
+                OnFailureFn(context, err);
+                return;
+            }
             [array_0 addObject:newElement_0];
         }
         CHIP_ERROR err = iter_0.GetStatus();
@@ -9019,9 +9027,12 @@
     MTROperationalStateClusterOperationalStateStruct * _Nonnull objCValue;
     objCValue = [MTROperationalStateClusterOperationalStateStruct new];
     objCValue.operationalStateID = [NSNumber numberWithUnsignedChar:chip::to_underlying(value.operationalStateID)];
-    objCValue.operationalStateLabel = [[NSString alloc] initWithBytes:value.operationalStateLabel.data()
-                                                               length:value.operationalStateLabel.size()
-                                                             encoding:NSUTF8StringEncoding];
+    objCValue.operationalStateLabel = AsString(value.operationalStateLabel);
+    if (objCValue.operationalStateLabel == nil) {
+        CHIP_ERROR err = CHIP_ERROR_INVALID_ARGUMENT;
+        OnFailureFn(context, err);
+        return;
+    }
     DispatchSuccess(context, objCValue);
 };
 
@@ -9049,14 +9060,20 @@
     if (value.errorStateLabel.IsNull()) {
         objCValue.errorStateLabel = nil;
     } else {
-        objCValue.errorStateLabel = [[NSString alloc] initWithBytes:value.errorStateLabel.Value().data()
-                                                             length:value.errorStateLabel.Value().size()
-                                                           encoding:NSUTF8StringEncoding];
+        objCValue.errorStateLabel = AsString(value.errorStateLabel.Value());
+        if (objCValue.errorStateLabel == nil) {
+            CHIP_ERROR err = CHIP_ERROR_INVALID_ARGUMENT;
+            OnFailureFn(context, err);
+            return;
+        }
     }
     if (value.errorStateDetails.HasValue()) {
-        objCValue.errorStateDetails = [[NSString alloc] initWithBytes:value.errorStateDetails.Value().data()
-                                                               length:value.errorStateDetails.Value().size()
-                                                             encoding:NSUTF8StringEncoding];
+        objCValue.errorStateDetails = AsString(value.errorStateDetails.Value());
+        if (objCValue.errorStateDetails == nil) {
+            CHIP_ERROR err = CHIP_ERROR_INVALID_ARGUMENT;
+            OnFailureFn(context, err);
+            return;
+        }
     } else {
         objCValue.errorStateDetails = nil;
     }
diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRCommandPayloadsObjc.mm b/src/darwin/Framework/CHIP/zap-generated/MTRCommandPayloadsObjc.mm
index 3d3d8ff..b3731db 100644
--- a/src/darwin/Framework/CHIP/zap-generated/MTRCommandPayloadsObjc.mm
+++ b/src/darwin/Framework/CHIP/zap-generated/MTRCommandPayloadsObjc.mm
@@ -6732,16 +6732,18 @@
         if (decodableStruct.commandResponseState.errorStateLabel.IsNull()) {
             self.commandResponseState.errorStateLabel = nil;
         } else {
-            self.commandResponseState.errorStateLabel =
-                [[NSString alloc] initWithBytes:decodableStruct.commandResponseState.errorStateLabel.Value().data()
-                                         length:decodableStruct.commandResponseState.errorStateLabel.Value().size()
-                                       encoding:NSUTF8StringEncoding];
+            self.commandResponseState.errorStateLabel = AsString(decodableStruct.commandResponseState.errorStateLabel.Value());
+            if (self.commandResponseState.errorStateLabel == nil) {
+                CHIP_ERROR err = CHIP_ERROR_INVALID_ARGUMENT;
+                return err;
+            }
         }
         if (decodableStruct.commandResponseState.errorStateDetails.HasValue()) {
-            self.commandResponseState.errorStateDetails =
-                [[NSString alloc] initWithBytes:decodableStruct.commandResponseState.errorStateDetails.Value().data()
-                                         length:decodableStruct.commandResponseState.errorStateDetails.Value().size()
-                                       encoding:NSUTF8StringEncoding];
+            self.commandResponseState.errorStateDetails = AsString(decodableStruct.commandResponseState.errorStateDetails.Value());
+            if (self.commandResponseState.errorStateDetails == nil) {
+                CHIP_ERROR err = CHIP_ERROR_INVALID_ARGUMENT;
+                return err;
+            }
         } else {
             self.commandResponseState.errorStateDetails = nil;
         }
diff --git a/src/darwin/Framework/CHIP/zap-generated/MTREventTLVValueDecoder.mm b/src/darwin/Framework/CHIP/zap-generated/MTREventTLVValueDecoder.mm
index 23417d1..6780e58 100644
--- a/src/darwin/Framework/CHIP/zap-generated/MTREventTLVValueDecoder.mm
+++ b/src/darwin/Framework/CHIP/zap-generated/MTREventTLVValueDecoder.mm
@@ -1775,14 +1775,20 @@
             if (cppValue.errorState.errorStateLabel.IsNull()) {
                 memberValue.errorStateLabel = nil;
             } else {
-                memberValue.errorStateLabel = [[NSString alloc] initWithBytes:cppValue.errorState.errorStateLabel.Value().data()
-                                                                       length:cppValue.errorState.errorStateLabel.Value().size()
-                                                                     encoding:NSUTF8StringEncoding];
+                memberValue.errorStateLabel = AsString(cppValue.errorState.errorStateLabel.Value());
+                if (memberValue.errorStateLabel == nil) {
+                    CHIP_ERROR err = CHIP_ERROR_INVALID_ARGUMENT;
+                    *aError = err;
+                    return nil;
+                }
             }
             if (cppValue.errorState.errorStateDetails.HasValue()) {
-                memberValue.errorStateDetails = [[NSString alloc] initWithBytes:cppValue.errorState.errorStateDetails.Value().data()
-                                                                         length:cppValue.errorState.errorStateDetails.Value().size()
-                                                                       encoding:NSUTF8StringEncoding];
+                memberValue.errorStateDetails = AsString(cppValue.errorState.errorStateDetails.Value());
+                if (memberValue.errorStateDetails == nil) {
+                    CHIP_ERROR err = CHIP_ERROR_INVALID_ARGUMENT;
+                    *aError = err;
+                    return nil;
+                }
             } else {
                 memberValue.errorStateDetails = nil;
             }