From adbab5fe22e0c62025010af873df36e1cb62e5ad Mon Sep 17 00:00:00 2001 From: Carl Brugger Date: Wed, 6 Mar 2024 19:12:29 -0600 Subject: [PATCH 1/2] fix: excel extractor password protected error messaging --- .changeset/giant-countries-brush.md | 5 +++++ plugins/xlsx-extractor/src/parser.ts | 2 ++ 2 files changed, 7 insertions(+) create mode 100644 .changeset/giant-countries-brush.md diff --git a/.changeset/giant-countries-brush.md b/.changeset/giant-countries-brush.md new file mode 100644 index 000000000..fab2dd324 --- /dev/null +++ b/.changeset/giant-countries-brush.md @@ -0,0 +1,5 @@ +--- +'@flatfile/plugin-xlsx-extractor': patch +--- + +This release improves the error messaging when extracting password-protected Excel files diff --git a/plugins/xlsx-extractor/src/parser.ts b/plugins/xlsx-extractor/src/parser.ts index d2cfeeb40..1fe70622a 100644 --- a/plugins/xlsx-extractor/src/parser.ts +++ b/plugins/xlsx-extractor/src/parser.ts @@ -38,6 +38,8 @@ export async function parseBuffer( throw new Error( 'File is too large to parse. Try converting this file to CSV.' ) + } else if (e.message === 'File is password-protected') { + throw new Error('File is password-protected') } } From 1df2188f53c25f82e50ec4ea0ca4aa386df58162 Mon Sep 17 00:00:00 2001 From: Carl Brugger Date: Tue, 12 Mar 2024 16:51:17 -0500 Subject: [PATCH 2/2] Update parser.ts --- plugins/xlsx-extractor/src/parser.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/plugins/xlsx-extractor/src/parser.ts b/plugins/xlsx-extractor/src/parser.ts index 1fe70622a..a655a63d7 100644 --- a/plugins/xlsx-extractor/src/parser.ts +++ b/plugins/xlsx-extractor/src/parser.ts @@ -26,7 +26,7 @@ export async function parseBuffer( WTF: true, }) } catch (e) { - // catch the error if the file is too large to parse, and throw a more helpful error. Otherwise, supress the error. + // catch the error if the file is too large to parse, and throw a more helpful error. // ref: https://docs.sheetjs.com/docs/miscellany/errors/#invalid-string-length-or-err_string_too_long // i.e. 'Cannot create a string longer than 0x1fffffe8 characters' if (e.code === 'ERR_STRING_TOO_LONG') { @@ -38,9 +38,8 @@ export async function parseBuffer( throw new Error( 'File is too large to parse. Try converting this file to CSV.' ) - } else if (e.message === 'File is password-protected') { - throw new Error('File is password-protected') } + throw e } const sheetNames = Object.keys(workbook.Sheets)