Repository navigation
Conversation
find_soffice() shelled out to ["which", "soffice"] after the known
install paths. A Windows host without Git has no which executable, so
subprocess.run raised FileNotFoundError, which escaped
normalize_excel_bytes() and replaced the documented ValueError ("the file
may be corrupt, encrypted, or not a spreadsheet") with a bare WinError 2
for every unrecognized spreadsheet.
Use shutil.which(), which is portable and also honours PATHEXT.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Observed
On a Windows host that has no Git/POSIX tools on
PATH, every spreadsheet DocReader cannot recognise fails with an opaque OS error instead of the documented message:Expected
find_soffice()returnsNone(LibreOffice is simply not installed), andnormalize_excel_bytes()raises theValueErrorit documents: "Unrecognized Excel file format; the file may be corrupt, encrypted, or not a spreadsheet".Root cause
find_soffice()falls back tosubprocess.run(["which", "soffice"])after checking the known install paths.whichis a POSIX tool; a Windows host without Git has no such executable, sosubprocess.runraisesFileNotFoundErrorbefore the probe can report "not found". The error propagates throughnormalize_excel_bytes()→ExcelParser, so a user uploading an encrypted or corrupt.xlsgetsWinError 2and no hint about the file.Linux and macOS always have
which, so CI never hits this path — the sibling call in the same module (subprocess.run(cmd, ...)) already guards itsOSErrorfor exactly this reason.Fix
Replace the subprocess probe with
shutil.which("soffice"), which is portable, returnsNonewhen the tool is missing, and honoursPATHEXTon Windows (sosoffice.exeis found as well). The explicit install-path list is kept, so non-PATHinstallations still resolve.Verification
The new test runs the probe with a
PATHthat has nowhich(on Windows: only the interpreter directory), reproducing the failing host without touching the module under test.