From f3fe4516b316e6ce6e9047379bb901dbea0a2486 Mon Sep 17 00:00:00 2001 From: Flavien David Date: Thu, 7 Mar 2024 21:50:18 +0100 Subject: [PATCH 1/2] Handle Sheet with gid = 0 --- .../src/connectors/google_drive/temporal/spreadsheets.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/connectors/src/connectors/google_drive/temporal/spreadsheets.ts b/connectors/src/connectors/google_drive/temporal/spreadsheets.ts index 3e65d2ff2d06..ee8352e74760 100644 --- a/connectors/src/connectors/google_drive/temporal/spreadsheets.ts +++ b/connectors/src/connectors/google_drive/temporal/spreadsheets.ts @@ -435,6 +435,7 @@ export async function syncSpreadSheet( // List synced sheets. const syncedSheets = await GoogleDriveSheet.findAll({ where: { + connectorId: connector.id, driveFileId: file.id, }, }); @@ -451,9 +452,11 @@ export async function syncSpreadSheet( // or have exceeded the maximum number of rows. const deletedSyncedSheets = syncedSheets.filter( (synced) => - !successfulSheetIdImports.find( + // Check for undefined explicitly, avoiding incorrect filtering + // due to falsy values (0 can be a valid sheet ID). + successfulSheetIdImports.find( (sheetId) => sheetId === synced.driveSheetId - ) + ) === undefined ); if (deletedSyncedSheets.length > 0) { await deleteAllSheets(connector, deletedSyncedSheets, { From 42d7ce74838d3cb096f8afe239905825cb31c65e Mon Sep 17 00:00:00 2001 From: Flavien David Date: Thu, 7 Mar 2024 21:59:03 +0100 Subject: [PATCH 2/2] Fix log --- .../src/connectors/google_drive/temporal/spreadsheets.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/connectors/src/connectors/google_drive/temporal/spreadsheets.ts b/connectors/src/connectors/google_drive/temporal/spreadsheets.ts index ee8352e74760..c3d88efe33c5 100644 --- a/connectors/src/connectors/google_drive/temporal/spreadsheets.ts +++ b/connectors/src/connectors/google_drive/temporal/spreadsheets.ts @@ -478,7 +478,9 @@ async function deleteSheetForSpreadsheet( { connectorId: connector.id, sheet, - spreadsheetFileId, + spreadsheet: { + id: spreadsheetFileId, + }, }, "[Spreadsheet] Deleting google drive sheet." );