Skip to content

extract_pdf_text silently returns "" when the optional pdf extra is missing — every PDF becomes an empty document #3702

Closed

Description

@gmos

detect.extract_pdf_text() wraps its whole body — including from pypdf import PdfReader — in except Exception: return "". pypdf is only installed behind the optional pdf extra, so an install of plain graphifyy turns every PDF in a corpus into an empty document: no error, no warning, no log line naming the missing dependency.

The only symptom reaches the user later, from the semantic pass:

[graphify] WARNING: 2/45 dispatched file(s) produced no nodes and are absent
from the graph: RFID_protocols.pdf, llrp_1_1-standard-20101013.pdf.
The model returned a response but omitted them; a re-run will retry them.

That reads as a model failure and sends you looking in the wrong place. "A re-run will retry them" is misleading too: every re-run fails identically, and a file that yields zero nodes gets no cache entry, so it is re-dispatched to the LLM forever.

Reproduce

  1. uv tool install graphifyy (no extras)
  2. Put any PDF with a text layer in the corpus
  3. graphify extract . --backend claude-cli

The PDF is found (found N code, M docs, 2 papers) and dispatched, and contributes nothing.

Our case

graphify 0.9.65, Python 3.14.4, claude-cli backend. Two EPCglobal specifications of ~3 MB each, which yield 435,386 and 407,013 characters once pypdf is present. They contributed 46 nodes under 0.8.33 — which handed the file to the model directly — and zero after the move to local text extraction. It went unnoticed for months; we only found it because a node count dropped for an unrelated reason and we went reading the installed source.

uv tool install "graphifyy[pdf]" --with "pypdf[crypto]" fixes it completely.

Suggested fixes, in order of value

  1. Let the ImportError surface, or catch it separately: PDF support requires the 'pdf' extra: uv tool install "graphifyy[pdf]". A missing dependency is not the same event as a malformed file, and except Exception conflates them.
  2. The same for pypdf's DependencyError on AES-encrypted PDFs, which needs pypdf[crypto] and currently fails the same silent way.
  3. When a dispatched file's text extraction comes back empty, say so before the LLM call, rather than reporting afterwards that the model omitted 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