Răsfoiți Sursa

fix: `not allowed types` error in the google sheet block

Ahmad Kholid 2 ani în urmă
părinte
comite
59c2b31ed3

+ 12 - 5
src/background/workflowEngine/blocksHandler/handlerGoogleSheets.js

@@ -64,16 +64,23 @@ async function updateSpreadsheetValues(
     if (keysAsFirstRow) {
       values = convertArrObjTo2DArr(columns);
     } else {
-      values = columns.map((item) =>
-        Object.values(item).map((value) =>
-          typeof value === 'object' ? JSON.stringify(value) : value
-        )
-      );
+      values = columns.map((item) => Object.values(item));
     }
   } else if (dataFrom === 'custom') {
     values = parseJSON(customData, customData);
   }
 
+  if (Array.isArray(values)) {
+    const validTypes = ['boolean', 'string', 'number'];
+    values.forEach((row, rowIndex) => {
+      row.forEach((column, colIndex) => {
+        if (column && validTypes.includes(typeof column)) return;
+
+        values[rowIndex][colIndex] = ' ';
+      });
+    });
+  }
+
   const queries = {
     valueInputOption: valueInputOption || 'RAW',
   };