Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Catch xlsx error #1487

Merged
merged 3 commits into from
Feb 12, 2025
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions apps/server/src/services/sheet-service/SheetService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,18 @@ 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',
);
}
revoke();
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure we need to revoke, maybe just clear the sheet ID?

I assume our issue is that we get stuck with a sheet that we can't read from

Also: does the revoke not need to come before throwing?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I our current flow we have tied sheet id and authentication together
should we spilt it into separate steps?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That sounds like we need to rebuild the UI?

In which case I guess we should make a less nice fix now to be able to release soon

const errorMessage = getErrorMessage(error);
throw new Error(`Failed to verify sheet: ${errorMessage}`);
}
Expand Down