{"record":{"id":"d5a309d1c353daad","repo":"docling-project/docling","slug":"input-file-is-not-valid-jsonl-or-a-json-summary","errorCode":null,"errorMessage":"{input_file} is not valid JSONL or a JSON summary report.","messagePattern":"(.+?) is not valid JSONL or a JSON summary report\\.","errorType":"console","errorClass":"SystemExit","httpStatus":null,"severity":"error","filePath":"perfs/plot_memory_metrics.py","lineNumber":40,"sourceCode":"    )\n    parser.add_argument(\n        \"-o\",\n        \"--output\",\n        type=Path,\n        default=Path(\"memory-metrics.png\"),\n        help=\"Output plot path.\",\n    )\n    return parser.parse_args()\n\n\ndef _resolve_metrics_files(input_file: Path) -> list[tuple[str, Path]]:\n    if input_file.suffix.lower() == \".jsonl\":\n        return [(input_file.stem, input_file)]\n\n    try:\n        report = json.loads(input_file.read_text(encoding=\"utf-8\"))\n    except json.JSONDecodeError as exc:\n        raise SystemExit(\n            f\"{input_file} is not valid JSONL or a JSON summary report.\"\n        ) from exc\n\n    runs = report.get(\"runs\")\n    if not isinstance(runs, list):\n        raise SystemExit(\n            f\"{input_file} does not look like an iterate_pdf_pages.py summary report.\"\n        )\n\n    metrics_files: list[tuple[str, Path]] = []\n    for index, run in enumerate(runs, start=1):\n        if not isinstance(run, dict):\n            continue\n        metrics_file = run.get(\"metrics_file\")\n        if not isinstance(metrics_file, str):\n            continue\n        thread_count = run.get(\"threads\")\n        label = (","sourceCodeStart":22,"sourceCodeEnd":58,"githubUrl":"https://github.com/docling-project/docling/blob/61d76f1ff3f8428065465889f7b4577da7df704c/perfs/plot_memory_metrics.py#L22-L58","documentation":"SystemExit raised by _resolve_metrics_files() in perfs/plot_memory_metrics.py when the input file is neither a .jsonl metrics file (dispatched earlier by suffix) nor parseable as JSON. The script falls back to treating the input as an iterate_pdf_pages.py JSON summary report, and json.loads() raising JSONDecodeError triggers this combined 'not JSONL nor JSON' message.","triggerScenarios":"Passing a --input file whose suffix is not .jsonl (so the JSONL fast path is skipped) and whose content is invalid JSON — e.g. a partially written report, a JSONL file renamed to .json, or a log file.","commonSituations":"A benchmark run was interrupted while writing the summary report, leaving truncated JSON; concatenating or hand-editing report files; passing the raw .jsonl metrics path but with a non-.jsonl extension, defeating the suffix check.","solutions":["If the file is line-delimited JSON events, rename it to end with .jsonl so the suffix fast path handles it.","If it should be a summary report, validate it parses: 'python -m json.tool report.json' and regenerate it by re-running iterate_pdf_pages.py.","Check the file tail for truncation ('tail -c 200 file') and re-run the benchmark if the writer was killed mid-report."],"exampleFix":"# before\n$ python perfs/plot_memory_metrics.py runs/metrics_events.txt   # jsonl content, wrong suffix\n# SystemExit: ... is not valid JSONL or a JSON summary report.\n\n# after\n$ mv runs/metrics_events.txt runs/metrics_events.jsonl\n$ python perfs/plot_memory_metrics.py runs/metrics_events.jsonl","handlingStrategy":"validation","validationCode":"import json\nfrom pathlib import Path\n\np = Path(input_file)\nif p.suffix.lower() != \".jsonl\":\n    try:\n        json.loads(p.read_text(encoding=\"utf-8\"))\n    except json.JSONDecodeError:\n        raise SystemExit(f\"{p} is neither .jsonl nor valid JSON; regenerate it\")","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep .jsonl metrics files suffixed .jsonl so the fast path handles them.","Treat truncated reports from killed runs as invalid and regenerate rather than patch.","Validate report files right after generation ('python -m json.tool') inside benchmark pipelines."],"tags":["perf-tooling","json","cli","file-format"],"backgroundTag":null,"analyzedSha":"61d76f1ff3f8428065465889f7b4577da7df704c","analyzedAt":"2026-08-14T23:53:18.727Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}