🚸 (googleSheets) Properly catch updateRow errors

This commit is contained in:
Baptiste Arnaud 2025-02-18 16:03:40 +01:00
parent a4358d6e21
commit 2597742521
No known key found for this signature in database

View File

@ -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<typeof filter>),
);
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<typeof filter>),
);
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);