From 2597742521cc4313ccfd103af79b8aef0c01aa93 Mon Sep 17 00:00:00 2001 From: Baptiste Arnaud Date: Tue, 18 Feb 2025 16:03:40 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=B8=20(googleSheets)=20Properly=20catc?= =?UTF-8?q?h=20updateRow=20errors?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../integrations/googleSheets/updateRow.ts | 44 +++++++++---------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/packages/bot-engine/src/blocks/integrations/googleSheets/updateRow.ts b/packages/bot-engine/src/blocks/integrations/googleSheets/updateRow.ts index 6f92c658e..28b028b03 100644 --- a/packages/bot-engine/src/blocks/integrations/googleSheets/updateRow.ts +++ b/packages/bot-engine/src/blocks/integrations/googleSheets/updateRow.ts @@ -46,29 +46,29 @@ export const updateRow = async ( workspaceId: state.workspaceId, }); - await doc.loadInfo(); - const sheet = doc.sheetsById[Number(sheetId)]; - const rows = await sheet.getRows(); - const filteredRows = rows.filter((row) => - referenceCell - ? row.get(referenceCell.column as string) === referenceCell.value - : matchFilter(row, filter as NonNullable), - ); - if (filteredRows.length === 0) { - logs.push({ - status: "info", - description: `Could not find any row that matches the filter`, - details: JSON.stringify(filter), - }); - return { outgoingEdgeId, logs }; - } - - const parsedValues = parseNewCellValuesObject(variables)( - options.cellsToUpsert, - sheet.headerValues, - ); - try { + await doc.loadInfo(); + const sheet = doc.sheetsById[Number(sheetId)]; + const rows = await sheet.getRows(); + const filteredRows = rows.filter((row) => + referenceCell + ? row.get(referenceCell.column as string) === referenceCell.value + : matchFilter(row, filter as NonNullable), + ); + if (filteredRows.length === 0) { + logs.push({ + status: "info", + description: `Could not find any row that matches the filter`, + details: JSON.stringify(filter), + }); + return { outgoingEdgeId, logs }; + } + + const parsedValues = parseNewCellValuesObject(variables)( + options.cellsToUpsert, + sheet.headerValues, + ); + for (const filteredRow of filteredRows) { const cellsRange = filteredRow.a1Range.split("!").pop(); await sheet.loadCells(cellsRange);