diff --git a/apps/client/src/features/app-settings/panel/sources-panel/GSheetSetup.tsx b/apps/client/src/features/app-settings/panel/sources-panel/GSheetSetup.tsx index 6212be3094..5fcf863c92 100644 --- a/apps/client/src/features/app-settings/panel/sources-panel/GSheetSetup.tsx +++ b/apps/client/src/features/app-settings/panel/sources-panel/GSheetSetup.tsx @@ -76,6 +76,7 @@ export default function GSheetSetup(props: GSheetSetupProps) { const handleConnect = async () => { if (!file) return; if (!sheetId) return; + patchStepData({ worksheet: { available: false, error: '' } }); setLoading('connect'); const result = await connect(file, sheetId); diff --git a/apps/server/src/services/sheet-service/SheetService.ts b/apps/server/src/services/sheet-service/SheetService.ts index 5f55203b7c..27337699b2 100644 --- a/apps/server/src/services/sheet-service/SheetService.ts +++ b/apps/server/src/services/sheet-service/SheetService.ts @@ -208,6 +208,17 @@ async function verifySheet( }); return { worksheetOptions: spreadsheets.data.sheets.map((i) => i.properties.title) }; } catch (error) { + // attempt to catch errors caused by importing xlsx + if ( + error.code === 400 && + Array.isArray(error.errors) && + error.errors[0].reason === 'failedPrecondition' && + error.errors[0].message === 'This operation is not supported for this document' + ) { + throw new Error( + 'This operation is not supported for this document. the reason is most likely that this is a .xlsx document', + ); + } const errorMessage = getErrorMessage(error); throw new Error(`Failed to verify sheet: ${errorMessage}`); }