{"record":{"id":"60117f9f8d4b91af","repo":"odysseus-dev/odysseus","slug":"invalid-json-in-path-exc-msg-at-line-exc-lin","errorCode":null,"errorMessage":"invalid JSON in {path}: {exc.msg} at line {exc.lineno}, column {exc.colno}","messagePattern":"invalid JSON in (.+?): (.+?) at line (.+?), column (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"scripts/pr_blocker_audit.py","lineNumber":159,"sourceCode":"    def finish_line(self) -> None:\n        if self.enabled and self.last_len:\n            self.stream.write(f\"\\r{' ' * self.last_len}\\r\")\n            self.stream.flush()\n            self.last_len = 0\n\n    def summary(self, message: str) -> None:\n        if self.enabled:\n            self.finish_line()\n            self.stream.write(f\"{message}\\n\")\n            self.stream.flush()\n\n\ndef load_json_file(path: Path):\n    try:\n        with path.open(\"r\", encoding=\"utf-8\") as handle:\n            return json.load(handle)\n    except json.JSONDecodeError as exc:\n        raise ValueError(f\"invalid JSON in {path}: {exc.msg} at line {exc.lineno}, column {exc.colno}\") from exc\n    except OSError as exc:\n        raise ValueError(f\"could not read {path}: {exc}\") from exc\n\n\ndef fetch_live_prs(repo: str, fetch_files: bool = True, progress: ProgressReporter | None = None, limit: int = 1000):\n    progress = progress or ProgressReporter(False)\n    fields = (\n        \"number,title,author,files,mergeStateStatus,reviewDecision,updatedAt,url\"\n        if fetch_files\n        else \"number,title,author,mergeStateStatus,reviewDecision,updatedAt,url\"\n    )\n    cmd = [\"gh\", \"pr\", \"list\", \"--repo\", repo, \"--state\", \"open\", \"--limit\", str(limit), \"--json\", fields]\n    progress.phase(\"Fetching open PR list...\")\n    try:\n        payload = _run_gh_json(cmd)\n    except RuntimeError:\n        api_path = f\"repos/{repo}/pulls?state=open&per_page=100\"\n        payload = _run_gh_json([\"gh\", \"api\", \"--paginate\", api_path])","sourceCodeStart":141,"sourceCodeEnd":177,"githubUrl":"https://github.com/odysseus-dev/odysseus/blob/f9235ebbf13f693a6fd29ce70b097f6ec83705bf/scripts/pr_blocker_audit.py#L141-L177","documentation":"Raised by load_json_file in scripts/pr_blocker_audit.py when a JSON file passed as an offline input (PR snapshot, cache, or config) fails to parse with json.load. The original json.JSONDecodeError message, line, and column are embedded, and the exception is re-raised as ValueError so callers only need to handle one exception type for bad input files.","triggerScenarios":"Running pr_blocker_audit.py with --input <file> (or any flag that loads a JSON snapshot) where the file has a syntax error: trailing comma, unescaped newline in a string, BOM, truncated download, or JSONL content fed where a single JSON document is expected.","commonSituations":"Hand-editing a gh pr list --json dump and breaking syntax; a partially-written/interrupted file capture; piping JSONL (one object per line) into an argument that expects one array; Windows BOM prepended by an editor.","solutions":["Open the file at the reported line/column and fix the JSON syntax error (the message gives the exact position).","Validate with an external tool first: python -m json.tool <file> or jq . <file> to get a second opinion on the error location.","If the file is JSONL or a gh --paginate capture, wrap it into a single array before passing it (e.g. jq -s . < in > out).","Re-capture the file from its source (gh pr list --json ...) instead of hand-editing."],"exampleFix":"# before\n$ python scripts/pr_blocker_audit.py --input prs.json\nValueError: invalid JSON in prs.json: Expecting ',' delimiter at line 12, column 5\n\n# after\n$ python -m json.tool prs.json   # locate/fix line 12\n$ python scripts/pr_blocker_audit.py --input prs.json","handlingStrategy":"validation","validationCode":"import json\nfrom pathlib import Path\n\ndef validate_json_input(path: str | Path) -> dict | list:\n    p = Path(path)\n    data = json.loads(p.read_text(encoding='utf-8-sig'))  # tolerate BOM\n    return data","typeGuard":"def is_valid_json_file(path: str) -> bool:\n    try:\n        with open(path, 'r', encoding='utf-8-sig') as fh:\n            json.load(fh)\n        return True\n    except (json.JSONDecodeError, OSError):\n        return False","tryCatchPattern":"try:\n    payload = load_json_file(Path(args.input))\nexcept ValueError as e:\n    if 'invalid JSON in' in str(e):\n        print(f'Fix the JSON syntax error: {e}', file=sys.stderr)\n    raise SystemExit(2)","preventionTips":["Generate input snapshots programmatically (gh pr list --json ... > file) instead of hand-editing.","Validate files with jq or python -m json.tool before passing them to the audit script.","Read with utf-8-sig in your own tooling to survive editor-added BOMs.","Keep one JSON document per file; wrap JSONL with jq -s . first."],"tags":["json","validation","cli","python"],"backgroundTag":null,"analyzedSha":"f9235ebbf13f693a6fd29ce70b097f6ec83705bf","analyzedAt":"2026-08-14T21:47:48.359Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}