NPE in Item.enrichProductFromVATBreakdown breaks validation in 2.25.0 (regression vs 2.24.0)
## Summary
Validating an existing Factur-X/ZUGFeRD PDF (EN16931 comfort profile) with
Mustang-CLI 2.25.0 aborts with a NullPointerException during import. The
resulting report has `<xml summary status="invalid">` and root
`<summary status="invalid">`, although schema and Schematron validation
themselves report no failed assertions -- the notices emitted are identical
to those from 2.24.0.
The same files validate as `valid` with Mustang-CLI 2.24.0.
## Environment
- Mustang-CLI 2.25.0 (Implementation-Version from MANIFEST.MF)
- Eclipse Temurin JDK 21.0.11+10, Windows Server
- Command: `java -jar Mustang-CLI-2.25.0.jar --action validate --source <file>`
## Observed
Out of 608 previously delivered invoices, 3 fail this way under 2.25.0 and
pass under 2.24.0. All other verdicts are byte-for-byte identical between
the two versions (input files verified unchanged via SHA-1).
[main] ERROR org.mustangproject.ZUGFeRD.ZUGFeRDInvoiceImporter - Failed to parse PDF
java.lang.NullPointerException: Cannot read field "scale" because "val" is null
at java.base/java.math.BigDecimal.compareTo(BigDecimal.java:3130)
at org.mustangproject.Item.enrichProductFromVATBreakdown(Item.java:402)
at org.mustangproject.ZUGFeRD.ZUGFeRDInvoiceImporter.extractInto(ZUGFeRDInvoiceImporter.java:1080)
at org.mustangproject.ZUGFeRD.ZUGFeRDInvoiceImporter.setDocument(ZUGFeRDInvoiceImporter.java:369)
at org.mustangproject.ZUGFeRD.ZUGFeRDInvoiceImporter.setRawXML(ZUGFeRDInvoiceImporter.java:307)
at org.mustangproject.ZUGFeRD.ZUGFeRDInvoiceImporter.setRawXML(ZUGFeRDInvoiceImporter.java:321)
at org.mustangproject.ZUGFeRD.ZUGFeRDInvoiceImporter.extractFiles(ZUGFeRDInvoiceImporter.java:280)
at org.mustangproject.ZUGFeRD.ZUGFeRDInvoiceImporter.extractLowLevel(ZUGFeRDInvoiceImporter.java:183)
at org.mustangproject.ZUGFeRD.ZUGFeRDInvoiceImporter.setInputStream(ZUGFeRDInvoiceImporter.java:130)
at org.mustangproject.validator.PDFValidator.validate(PDFValidator.java:147)
The report contains the exception as `<exception type="22">`.
## Note on `--no-arithmetic-check`
With `--no-arithmetic-check` the verdict returns to `valid` (root, xml and pdf),
but the NullPointerException is still logged to stderr. So the crash happens
regardless; the flag only suppresses its effect on the verdict.
## Expected
Either the importer should tolerate the null value, or -- if the input really
is invalid -- the report should say which business term is at fault instead of
surfacing a NullPointerException.
I can provide a redacted sample document by e-mail if that helps.
2 条评论