MadsLorentzen/ai-job-search · error · VerificationError

could not write --dump-text to {dump_path}: {exc}

Error message

could not write --dump-text to {dump_path}: {exc}

What it means

Raised when verify_pdf() was given a --dump-text/dump_text destination that could not be written. The dump is written before any content checks so failed verifications still leave a .txt, so an unwritable destination aborts the whole verification with this wrapped OSError.

Source

Thrown at tools/verify_pdf.py:107

def verify_pdf(pdf_path, expected_pages=None, min_chars=1, required_text=(), dump_text=None):
    pdf_path = Path(pdf_path)
    if not pdf_path.is_file():
        raise VerificationError(f"PDF does not exist: {pdf_path}")

    extracted_text, actual_pages, extractor = extract_text_layer(pdf_path)

    # Write dump *before* the checks so a failed verification still leaves a .txt
    if dump_text is not None:
        dump_path = Path(dump_text)
        try:
            dump_path.parent.mkdir(parents=True, exist_ok=True)
            dump_path.write_text(
                extracted_text if extracted_text.endswith("\n") else extracted_text + "\n",
                encoding="utf-8",
            )
        except OSError as exc:
            raise VerificationError(
                f"could not write --dump-text to {dump_path}: {exc}"
            ) from exc

    if expected_pages is not None and actual_pages != expected_pages:
        raise VerificationError(
            f"expected {expected_pages} page(s), found {actual_pages} (extractor: {extractor})"
        )

    normalized = normalize_text(extracted_text)
    if len(normalized) < min_chars:
        raise VerificationError(
            f"text layer has {len(normalized)} character(s); expected at least {min_chars} "
            f"(extractor: {extractor})"
        )

    for required in required_text:
        if normalize_text(required) not in normalized:
            raise VerificationError(

View on GitHub (pinned to 79cd383e58)

Solutions

  1. Check permissions on the dump directory and write to a writable location (e.g. a temp dir or CI artifact dir)
  2. Ensure the parent directory can be created or pre-create it yourself
  3. Verify disk space and that the path is not an existing directory
  4. As a workaround run verify_pdf without dump_text to isolate the verification from the dump failure

Example fix

// before
verify_pdf(pdf, dump_text='/var/locked/dump.txt')
// after
import tempfile, os
dump = os.path.join(tempfile.mkdtemp(), 'dump.txt')
verify_pdf(pdf, dump_text=dump)
Defensive patterns

Strategy: try-catch

Validate before calling

from pathlib import Path
d = Path(dump_text).parent
writable = (d.exists() and os.access(d, os.W_OK)) or os.access(d.parent if d.parent.exists() else Path.cwd(), os.W_OK)

Try / catch

try:
    verify_pdf(pdf, dump_text=dump)
except VerificationError as e:
    if 'dump-text' in str(e):
        verify_pdf(pdf)  # retry without the dump

Prevention

When it happens

Trigger: Passing dump_text pointing to a directory without write permission, a path whose parent cannot be created (read-only filesystem, permission denied, disk full), or a path that collides with an existing directory. Any OSError from mkdir() or write_text() is caught and re-raised as VerificationError.

Common situations: CI containers running as a non-root user writing to protected paths; read-only mount or sandboxed tmpdir; dump path typo like '/root/out.txt'; ENOSPC on full disks in build agents.

Related errors


AI-assisted analysis of MadsLorentzen/ai-job-search@79cd383e58 (2026-08-27). Data as JSON: /api/errors/bc7f33c1279789df. Report an issue: GitHub.