Fix PDF/A validation reporting internal_error after veraPDF 1.30.x upgrade - #1663
Open
jordanpadams wants to merge 2 commits into
Open
Fix PDF/A validation reporting internal_error after veraPDF 1.30.x upgrade#1663jordanpadams wants to merge 2 commits into
jordanpadams wants to merge 2 commits into
Conversation
…o 1.30.x (#1662) veraPDF 1.30+ throws IndexOutOfBoundsException from PDFAParser.getFlavour() for PDFs with no pdfaid conformance declaration, instead of returning a default flavour as 1.28.x did. The outer catch in validatePDF() was re-throwing this as IOException, which FileReferenceValidationRule caught as INTERNAL_ERROR instead of NON_PDFA_FILE. Fix by catching IndexOutOfBoundsException from getFlavour() specifically and treating it as a missing conformance declaration (return false with an appropriate errorMessage). Also adds an explicit NO_FLAVOUR guard for future veraPDF versions that may return NO_FLAVOUR cleanly. Bumps org.verapdf:validation-model-jakarta from 1.28.2 to 1.30.2. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Resolves two SonarCloud findings on PR #1663: - java:S1141: nested try extracted into detectFlavour() helper - java:S125: removed comment block flagged as commented-out code detectFlavour() returns null (instead of NO_FLAVOUR sentinel) when the PDF has no conformance declaration, unifying the IndexOutOfBoundsException and NO_FLAVOUR cases into a single null check in the caller. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
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.



🗒️ Summary
Fixes a regression introduced by upgrading
org.verapdf:validation-model-jakartafrom 1.28.2 to 1.30.2.Root cause: veraPDF 1.30+ changed behavior in
PDFAParser.getFlavour(). For PDFs with nopdfaidconformance declaration in their XMP metadata, the method now throwsIndexOutOfBoundsException(accessing an empty list at index 0) instead of returning a default flavour as 1.28.x did. The exception propagated throughPDFUtil.validatePDF()'s outer catch block, was re-thrown asIOException, and was then caught byFileReferenceValidationRule.handlePDF()asINTERNAL_ERRORrather than the expectedNON_PDFA_FILE.Fix: Catch
IndexOutOfBoundsExceptionfromgetFlavour()specifically and treat it as a missing conformance declaration — seterrorMessageand returnfalse(non-compliant). Also adds an explicitNO_FLAVOURguard for future veraPDF versions that may returnNO_FLAVOURcleanly instead of throwing.Confirmed by investigation:
github1008/example.pdf,github164/invalid/test1_pdf.pdf,github824/1203_12.PDF) are plain PDFs with nopdfaidXMP metadata, verified viaqpdf --qdf --decode-level=noneraw stream extractiongetFlavour()guessedPDFA_1_Bas a default → validation failed →NON_PDFA_FILEraised (correct outcome, accidental path)getFlavour()throwsIndexOutOfBoundsException→ previously becameINTERNAL_ERRORChanges:
pom.xml: bumpvalidation-model-jakarta1.28.2 → 1.30.2 (fixes CVE on 1.28.2)PDFUtil.java: catchIndexOutOfBoundsExceptionfromgetFlavour()and treat as missing PDF/A declarationAI Assistance: This fix was developed with AI assistance (investigation, root cause analysis, and implementation). The logic was verified against actual test PDFs and confirmed passing all targeted test scenarios.
⚙️ Test Data and/or Report
Targeted scenarios verified locally with veraPDF 1.30.2:
NASA-PDS/validate#1008-1✅error.pdf.file.not_pdfa_compliant=1NASA-PDS/validate#366-1✅error.pdf.file.not_pdfa_compliant=1NASA-PDS/validate#164-1✅error.pdf.file.not_pdfa_compliant=1NASA-PDS/validate#824-1✅ 0 errorsNASA-PDS/validate#824-2✅ 0 errorsFull
@v3.7.xtest suite running in CI.♻️ Related Issues
Fixes #1662
Closes #1625
🤓 Reviewer Checklist