{"record":{"id":"bc7f33c1279789df","repo":"MadsLorentzen/ai-job-search","slug":"could-not-write-dump-text-to-dump-path-exc","errorCode":null,"errorMessage":"could not write --dump-text to {dump_path}: {exc}","messagePattern":"could not write --dump-text to (.+?): (.+?)","errorType":"exception","errorClass":"VerificationError","httpStatus":null,"severity":"error","filePath":"tools/verify_pdf.py","lineNumber":107,"sourceCode":"\ndef verify_pdf(pdf_path, expected_pages=None, min_chars=1, required_text=(), dump_text=None):\n    pdf_path = Path(pdf_path)\n    if not pdf_path.is_file():\n        raise VerificationError(f\"PDF does not exist: {pdf_path}\")\n\n    extracted_text, actual_pages, extractor = extract_text_layer(pdf_path)\n\n    # Write dump *before* the checks so a failed verification still leaves a .txt\n    if dump_text is not None:\n        dump_path = Path(dump_text)\n        try:\n            dump_path.parent.mkdir(parents=True, exist_ok=True)\n            dump_path.write_text(\n                extracted_text if extracted_text.endswith(\"\\n\") else extracted_text + \"\\n\",\n                encoding=\"utf-8\",\n            )\n        except OSError as exc:\n            raise VerificationError(\n                f\"could not write --dump-text to {dump_path}: {exc}\"\n            ) from exc\n\n    if expected_pages is not None and actual_pages != expected_pages:\n        raise VerificationError(\n            f\"expected {expected_pages} page(s), found {actual_pages} (extractor: {extractor})\"\n        )\n\n    normalized = normalize_text(extracted_text)\n    if len(normalized) < min_chars:\n        raise VerificationError(\n            f\"text layer has {len(normalized)} character(s); expected at least {min_chars} \"\n            f\"(extractor: {extractor})\"\n        )\n\n    for required in required_text:\n        if normalize_text(required) not in normalized:\n            raise VerificationError(","sourceCodeStart":89,"sourceCodeEnd":125,"githubUrl":"https://github.com/MadsLorentzen/ai-job-search/blob/79cd383e58f0af7948c7c6462a3a289e9b67421e/tools/verify_pdf.py#L89-L125","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Check permissions on the dump directory and write to a writable location (e.g. a temp dir or CI artifact dir)","Ensure the parent directory can be created or pre-create it yourself","Verify disk space and that the path is not an existing directory","As a workaround run verify_pdf without dump_text to isolate the verification from the dump failure"],"exampleFix":"// before\nverify_pdf(pdf, dump_text='/var/locked/dump.txt')\n// after\nimport tempfile, os\ndump = os.path.join(tempfile.mkdtemp(), 'dump.txt')\nverify_pdf(pdf, dump_text=dump)","handlingStrategy":"try-catch","validationCode":"from pathlib import Path\nd = Path(dump_text).parent\nwritable = (d.exists() and os.access(d, os.W_OK)) or os.access(d.parent if d.parent.exists() else Path.cwd(), os.W_OK)","typeGuard":null,"tryCatchPattern":"try:\n    verify_pdf(pdf, dump_text=dump)\nexcept VerificationError as e:\n    if 'dump-text' in str(e):\n        verify_pdf(pdf)  # retry without the dump","preventionTips":["Write dumps to a temp dir or CI artifact dir with known permissions","Pre-create the dump directory in setup","Treat dump failures as non-fatal by calling without dump_text when it fails"],"tags":["pdf","io","permissions","oserror","dump-text"],"backgroundTag":null,"analyzedSha":"79cd383e58f0af7948c7c6462a3a289e9b67421e","analyzedAt":"2026-08-27T21:51:12.330Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}