{"record":{"id":"d4597296f4ed2889","repo":"Stirling-Tools/Stirling-PDF","slug":"file-not-found-json-path","errorCode":null,"errorMessage":"File not found: {json_path}","messagePattern":"File not found: (.+?)","errorType":"exception","errorClass":"SystemExit","httpStatus":null,"severity":"warning","filePath":"scripts/analyze_pdf_json.py","lineNumber":211,"sourceCode":"    return DocumentBreakdown(\n        total_bytes=total_size,\n        fonts=font_stats,\n        pages=page_stats,\n        metadata_bytes=approx_struct_size(metadata),\n        xmp_bytes=base64_payload_size(document.get(\"xmpMetadata\")),\n        form_fields_bytes=approx_struct_size(document.get(\"formFields\")),\n        lazy_flag_bytes=approx_struct_size(document.get(\"lazyImages\")),\n    )\n\n\ndef main() -> None:\n    parser = argparse.ArgumentParser(description=\"Inspect a PDF JSON export.\")\n    parser.add_argument(\"json_path\", type=Path, help=\"Path to the JSON export.\")\n    args = parser.parse_args()\n\n    json_path = args.json_path\n    if not json_path.exists():\n        raise SystemExit(f\"File not found: {json_path}\")\n\n    file_size = json_path.stat().st_size\n    print(f\"File: {json_path}\")\n    print(f\"Size: {human_bytes(file_size)} ({file_size:,} bytes)\")\n\n    with json_path.open(\"r\", encoding=\"utf-8\") as handle:\n        document = json.load(handle)\n\n    if not isinstance(document, dict):\n        raise SystemExit(\"Unexpected JSON structure (expected an object at root).\")\n\n    summary = analyze_document(document, file_size)\n    page_stats = summary.pages\n    print(f\"Pages: {page_stats.page_count}\")\n    print(f\"Total text elements: {page_stats.total_text_elements:,}\")\n    print(f\"Total image elements: {page_stats.total_image_elements:,}\")\n    print(\n        f\"Page structural bytes (text arrays + images + streams + annotations): \"","sourceCodeStart":193,"sourceCodeEnd":229,"githubUrl":"https://github.com/Stirling-Tools/Stirling-PDF/blob/9ef20dcab80b85041912f045e17a6aea1d08f969/scripts/analyze_pdf_json.py#L193-L229","documentation":"SystemExit raised by the analyze_pdf_json.py CLI when the supplied json_path does not exist on the filesystem. This is a pre-flight validation check before attempting to open/parse the file.","triggerScenarios":"Running 'python scripts/analyze_pdf_json.py <path>' where <path> points to a nonexistent file — typo, wrong relative path, or the export was never generated.","commonSituations":"Typo in the path argument. Running from the wrong working directory (relative path mismatch). The PDF JSON export was never produced or was deleted.","solutions":["Verify the file exists: ls -la <path> before running.","Use an absolute path to avoid working-directory confusion.","Generate the JSON export first (export from the PDF text editor) if it does not exist."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"# Validate before invoking the analyzer\nimport sys\nfrom pathlib import Path\np = Path(sys.argv[1])\nif not p.exists():\n    print(f\"Not found: {p}\", file=sys.stderr); sys.exit(1)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pass absolute paths to CLI tools.","Generate the PDF JSON export before running the analyzer.","Tab-complete / ls the path to catch typos."],"tags":["cli","filesystem","python","validation","scripts"],"backgroundTag":null,"analyzedSha":"9ef20dcab80b85041912f045e17a6aea1d08f969","analyzedAt":"2026-08-13T22:11:39.827Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}