Skip to content

Fix PDF/A validation reporting internal_error after veraPDF 1.30.x upgrade - #1663

Open
jordanpadams wants to merge 2 commits into
mainfrom
bugfix/1662-verapdf-1.30-pdfa-compliance
Open

Fix PDF/A validation reporting internal_error after veraPDF 1.30.x upgrade#1663
jordanpadams wants to merge 2 commits into
mainfrom
bugfix/1662-verapdf-1.30-pdfa-compliance

Conversation

@jordanpadams

Copy link
Copy Markdown
Member

🗒️ Summary

Fixes a regression introduced by upgrading org.verapdf:validation-model-jakarta from 1.28.2 to 1.30.2.

Root cause: veraPDF 1.30+ changed behavior in PDFAParser.getFlavour(). For PDFs with no pdfaid conformance declaration in their XMP metadata, the method now throws IndexOutOfBoundsException (accessing an empty list at index 0) instead of returning a default flavour as 1.28.x did. The exception propagated through PDFUtil.validatePDF()'s outer catch block, was re-thrown as IOException, and was then caught by FileReferenceValidationRule.handlePDF() as INTERNAL_ERROR rather than the expected NON_PDFA_FILE.

Fix: Catch IndexOutOfBoundsException from getFlavour() specifically and treat it as a missing conformance declaration — set errorMessage and return false (non-compliant). Also adds an explicit NO_FLAVOUR guard for future veraPDF versions that may return NO_FLAVOUR cleanly instead of throwing.

Confirmed by investigation:

  • All failing test PDFs (github1008/example.pdf, github164/invalid/test1_pdf.pdf, github824/1203_12.PDF) are plain PDFs with no pdfaid XMP metadata, verified via qpdf --qdf --decode-level=none raw stream extraction
  • Under 1.28.2, getFlavour() guessed PDFA_1_B as a default → validation failed → NON_PDFA_FILE raised (correct outcome, accidental path)
  • Under 1.30.2, getFlavour() throws IndexOutOfBoundsException → previously became INTERNAL_ERROR

Changes:

  • pom.xml: bump validation-model-jakarta 1.28.2 → 1.30.2 (fixes CVE on 1.28.2)
  • PDFUtil.java: catch IndexOutOfBoundsException from getFlavour() and treat as missing PDF/A declaration

🤖 Generated with Claude Code

AI 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-1error.pdf.file.not_pdfa_compliant=1
  • NASA-PDS/validate#366-1error.pdf.file.not_pdfa_compliant=1
  • NASA-PDS/validate#164-1error.pdf.file.not_pdfa_compliant=1
  • NASA-PDS/validate#824-1 ✅ 0 errors
  • NASA-PDS/validate#824-2 ✅ 0 errors

Full @v3.7.x test suite running in CI.

♻️ Related Issues

Fixes #1662
Closes #1625

🤓 Reviewer Checklist

  • Documentation - Is the new feature/change adequately documented?
  • Security - Are there any security implications to these changes?
  • Testing - Have tests been added/updated? Are edge cases covered?
  • Dependencies - Are dependency changes appropriate and minimal?

…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>
@jordanpadams
jordanpadams requested a review from a team as a code owner August 22, 2026 17:46
@jordanpadams jordanpadams added the bug Something isn't working label Aug 22, 2026
@jordanpadams jordanpadams self-assigned this Aug 22, 2026
@jordanpadams jordanpadams added the bug Something isn't working label Aug 22, 2026
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>
@sonarqubecloud

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PDF/A validation reports internal_error instead of not_pdfa_compliant after veraPDF upgrade to 1.30.x

1 participant