openpreserve / odf-validator

Open source Open Document Format (ODF) validation
http://odf.openpreservation.org/
BSD 3-Clause "New" or "Revised" License
3 stars 0 forks source link

Error PKG-1 when file not found #149

Open maria-messerschmidt opened 2 months ago

maria-messerschmidt commented 2 months ago

When the validator is executed, and the file is not found, an error is thrown. But the error message is:

PKG-1: alm.ods [ERROR] An OpenDocument Package shall be a well formed Zip Archive. POL-2: alm.ods [ERROR] Standard Compliance | The file MUST comply with the standard "OASIS Open Document Document Format for Office Applications (OpenDocument) v1.3".

This is somewhat misleading when the file does in fact not exist.

carlwilson commented 2 months ago

Hi @maria-messerschmidt I'll look at this soon, I assume it's when the CLI app is used. I'd agree that a clear message should be sent when either:

I'll look to produce a candidate fix for next week if you concur.

maria-messerschmidt commented 2 months ago

Thanks! Let me get back to you tomorrow. I managed to get a "File does not exist" error, so I need to figure out under what circumstances it works and doesn't work.

maria-messerschmidt commented 2 months ago

Ok, so this only happens, when I run the validator with -p (but of course, I use that in most cases). I think the error produced when running it without -p is fine, it just needs to also produce the error when running with -p.

C:\odf\odf-validator-main>odf-validator.bat "filer/testfiler/xxx.ods" APP-1: [INFO] Validating filer\testfiler\xxx.ods. APP-2: [ERROR] Supplied Path parameter: filer\testfiler\xxx.ods does not exist.

C:\odf\odf-validator-main>odf-validator.bat -p filer/testfiler/xxx.ods" APP-1: [INFO] Validating filer\testfiler\xxx.ods. APP-5: [INFO] DNA ODF Spreadsheets Preservation Specification Profile report for filer\testfiler\xxx.ods. PKG-1: xxx.ods [ERROR] An OpenDocument Package SHALL be a well formed Zip Archive. POL_2: xxx.ods [ERROR] Standard Compliance | The file MUST comply with the standard "OASIS Open Document Format for Office Applications (OpenDocument) v1.3". NOT VALID, 2 errors, 0 warnings and 0 info messages.

carlwilson commented 2 months ago

OK, that looks a straightforward fix, and possibly a little refactor to get the option thing in line.

carlwilson commented 2 months ago

Hi @maria-messerschmidt there is now a PR that fixes this issue. If you want to take a look and test its #158

maria-messerschmidt commented 1 month ago

Fix is working for this issue. I now get the same error message whether I run it with or without -p.

C:\odf\odf-validator-fix-missing-file-profile>odf-validator.bat -p testfiler/T001.ods APP-1: [INFO] Validating testfiler\T001.ods. APP-2: [ERROR] Supplied Path parameter: testfiler\T001.ods does not exist.

C:\odf\odf-validator-fix-missing-file-profile>odf-validator.bat testfiler/T001.ods APP-1: [INFO] Validating testfiler\T001.ods. APP-2: [ERROR] Supplied Path parameter: testfiler\T001.ods does not exist.

I can see in the changes to CliValidator that you aligned the checks for with/without profile for the FileNotFound exception. But I noticed that the IOException (which was moved to line 82) is not identical to the equivalent line for running the validator without the profile (line 71) which contains three exceptions (ParserConfigurationException | SAXException | IOException). I have not managed to trigger any of these exceptions, but I was wondering whether there is a reason for the discrepancy?