Skip to content

extract_pdf_text returns "" silently on extraction failure (indistinguishable from an empty PDF) #4527

Open

Description

@grazenN

extract_pdf_text wraps its entire PdfReader loop in except Exception: return "", so a malformed, encrypted, or otherwise unreadable PDF is indistinguishable from a PDF with no text. Downstream consumers (knowledge-graph builders, RAG indexers) count the document as "empty" rather than "failed" — in our pipeline this was a coverage-audit blind spot: files producing zero nodes with no trace anywhere, undetectable without re-running extraction manually.

Suggested shape: a warning to stderr naming the file and the exception class before returning (or a distinct sentinel), and a separate warning when the result is near-empty (so scanned/image-only PDFs are visible in logs rather than silently skipped — related: the OCR gap in #181).

We implemented both locally (a warning on failure; a near-empty-result warning; an optional OCR fallback for the latter case) and they turned silent data loss into visible, countable events. Small patch, happy to PR.

Environment: graphifyy 0.9.92, Python 3.13, pypdf (pdf extra).

Activity

  1. github-actions commented on Oct 17, 2026

    @github-actions

    Thanks for opening this issue, @grazenN. A maintainer will take a look soon.

    If you would like to discuss it in real time, come say hi on our Discord server. For longer-form questions and ideas there is also GitHub Discussions.

    To help us triage, please make sure the report includes what you expected, what actually happened, and the steps (and a small sample) to reproduce it.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions