Skip to content

fix: Detect password-protected PDFs when docling omits the PDFium reason (release-cpd-0.8.0-patch10) - #2541

Open
mpawlow wants to merge 1 commit into
release-cpd-0.8.0-patch10from
mp/fix/cpd-080-p10/gh-99817-password-protected-pdf-docling
Open

mpawlow wants to merge 1 commit into
release-cpd-0.8.0-patch10from
mp/fix/cpd-080-p10/gh-99817-password-protected-pdf-docling

Conversation

@mpawlow

@mpawlow mpawlow commented Oct 23, 2026 •

Copy link
Copy Markdown
Collaborator

ℹ️ Issue

ℹ️ Summary

  • Fixed password-protected PDF detection for newer docling versions.
  • Recovered the password-protected reason from the file bytes, because docling-parse no longer reports Incorrect password.
  • Restored the user-facing password-protected message in the task failure metadata for both the Langflow and non-Langflow ingestion paths.

🐛 Bug Fixes

  • Fixed password-protected PDFs failing with a generic Could not load document error.
    • docling 2.108 pre-opened PDFs with pypdfium2 (error: Incorrect password).
    • Later versions load through docling-parse first, which reports only Failed to load document with key ....
  • Added a byte-scan check for an /Encrypt entry (indirect reference or direct dictionary) in docling_service.py.
    • Added is_docling_load_failure(), is_encrypted_pdf() and password_protected_pdf_error().
    • Added the PASSWORD_PROTECTED_PDF_DETAIL constant, keeping the incorrect password substring that task_service maps to the user-facing message.
    • Applied the check only after docling failed to load the file, so owner-password-only PDFs that convert fine are unaffected.
  • Added DoclingService._get_result_for_content() and routed convert_bytes() and the upload-and-convert path through it.
    • Re-raised DoclingServeError with the password-protected detail and logged a warning.
  • Updated LangflowFileService to apply password_protected_pdf_error() to a FAILED poll result before raising.

♻️ Refactoring

  • Updated the _infer_failure_metadata comment in task_service.py to document that the backend now recovers the reason from the file bytes.
    • No behavior change.

🧪 Tests

  • Added tests in test_docling_service.py for:
    • is_encrypted_pdf() (parametrized).
    • password_protected_pdf_error() requiring both a load failure and encryption.
    • convert_bytes() naming a password-protected PDF.
    • convert_file() keeping the original docling error for an unencrypted PDF.
  • Added tests in test_langflow_file_service_two_phase.py for a docling load failure on:
    • An encrypted PDF (named as password-protected).
    • An unencrypted PDF (original docling detail kept).
  • Added a parametrized test in test_task_service_get_task_status2.py mapping a backend-detected password-protected PDF to the clean failure message.

@coderabbitai

coderabbitai Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added backend 🔷 Issues related to backend services (OpenSearch, Langflow, APIs) tests bug 🔴 Something isn't working. labels Oct 23, 2026
@mpawlow mpawlow changed the title fix: Detect password-protected PDFs when docling omits the PDFium reason fix: Detect password-protected PDFs when docling omits the PDFium reason (release-cpd-0.8.0-patch10) Oct 23, 2026
@github-actions github-actions Bot added bug 🔴 Something isn't working. and removed bug 🔴 Something isn't working. labels Oct 23, 2026
Issue

- https://github.ibm.com/lakehouse/tracker/issues/99817

Summary

- Recovered the password-protected reason from the file bytes when
  newer docling (docling-parse) no longer reports "Incorrect password".
- Restored the user-facing password-protected message in the task
  failure metadata for both the Langflow and non-Langflow paths.
@mpawlow
mpawlow force-pushed the mp/fix/cpd-080-p10/gh-99817-password-protected-pdf-docling branch from 0cba68e to a52be62 Compare October 23, 2026 20:52
@github-actions github-actions Bot added bug 🔴 Something isn't working. and removed bug 🔴 Something isn't working. labels Oct 23, 2026

This branch has not been deployed

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

Labels

backend 🔷 Issues related to backend services (OpenSearch, Langflow, APIs) bug 🔴 Something isn't working. tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant