{"record":{"id":"1c44c6ce28d62b30","repo":"nextlevelbuilder/ui-ux-pro-max-skill","slug":"invalid-json-file-path-error","errorCode":null,"errorMessage":"Invalid JSON file {path}: {error}","messagePattern":"Invalid JSON file (.+?): (.+?)","errorType":"console","errorClass":"SystemExit","httpStatus":null,"severity":"error","filePath":"scripts/evaluate-relevance.py","lineNumber":31,"sourceCode":"FIXTURE_DIR = RUNTIME_DIR / \"tests/fixtures\"\nsys.path.insert(0, str(RUNTIME_DIR))\nsys.path.insert(0, str(ROOT / \"scripts\"))\n\nfrom core import (AVAILABLE_STACKS, CSV_CONFIG, DATA_DIR, STACK_CONFIG,\n                  search, search_stack)  # noqa: E402\nfrom design_system import DesignSystemGenerator, _palette_is_dark  # noqa: E402\nfrom relevance_metrics import (REQUIRED_METRICS, check_thresholds, grades_for_results, ndcg_at_k,\n                               precision_at_k, reciprocal_rank, validate_fixture,\n                               validate_manifest)  # noqa: E402\n\n\ndef load_json(path):\n    def reject_constant(value):\n        raise ValueError(f\"non-RFC JSON numeric constant: {value}\")\n    try:\n        return json.loads(path.read_text(encoding=\"utf-8\"), parse_constant=reject_constant)\n    except (json.JSONDecodeError, OSError, ValueError) as error:\n        raise SystemExit(f\"Invalid JSON file {path}: {error}\") from error\n\n\ndef runtime_fingerprint():\n    paths = [\n        RUNTIME_DIR / \"core.py\",\n        RUNTIME_DIR / \"design_system.py\",\n        RUNTIME_DIR / \"reasoning_contract.py\",\n    ]\n    paths += sorted(DATA_DIR.rglob(\"*.csv\"))\n    digest = hashlib.sha256()\n    for path in paths:\n        digest.update(path.relative_to(ROOT).as_posix().encode() + b\"\\0\")\n        digest.update(path.read_bytes() + b\"\\0\")\n    return digest.hexdigest()\n\n\ndef oracle_fingerprint(cases_path=None):\n    \"\"\"Bind approvals to the judgments and the code that grades them.\"\"\"","sourceCodeStart":13,"sourceCodeEnd":49,"githubUrl":"https://github.com/nextlevelbuilder/ui-ux-pro-max-skill/blob/a38d04c3d5c298c851dbe5e6ee1965ee3de42cb5/scripts/evaluate-relevance.py#L13-L49","documentation":"load_json() in the relevance evaluation harness parses fixture/manifest JSON strictly: JSONDecodeError (syntax), OSError (unreadable/missing file), and ValueError are all converted into SystemExit with the offending path. The parse_constant hook also makes NaN/Infinity/-Infinity a ValueError, so even syntactically valid JSON containing those constants is rejected.","triggerScenarios":"Running scripts/evaluate-relevance.py with a --cases/--thresholds/--baseline file that has a trailing comma, unquoted keys, a BOM, or NaN/Infinity literals; pointing the flag at a file that doesn't exist or isn't readable; a fixture hand-edited and saved with smart quotes.","commonSituations":"Editing relevance-cases.json and leaving a trailing comma; Python json.dump emitting NaN when allow_nan isn't disabled; passing a relative path from the wrong CWD; BOM/CRLF artifacts from Windows editors.","solutions":["Validate the file with a strict parser: `python3 -m json.tool <file>` shows the syntax error location.","Remove NaN/Infinity constants — use null or omit the key.","Check the path passed via --cases/--thresholds/--baseline exists and is readable from the CWD you run from.","Re-save without BOM (plain UTF-8) if the error points at character 0."],"exampleFix":"# before\n{\"grades\": [3, NaN]}\n# after\n{\"grades\": [3, null]}","handlingStrategy":"validation","validationCode":"import json\nfrom pathlib import Path\n\ndef strict_load(path: Path):\n    text = path.read_text(encoding='utf-8-sig')  # strips BOM if present\n    def reject(c):\n        raise ValueError(f'{c} is not allowed in fixtures')\n    return json.loads(text, parse_constant=reject)\n\n# fail before evaluation if any input file is bad\nstrict_load(Path('tests/fixtures/relevance-cases.json'))","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Run `python3 -m json.tool file.json` on every edited fixture before invoking the harness.","Disallow NaN/Infinity in producers: json.dump(..., allow_nan=False).","Keep fixtures in version control and review diffs instead of regenerating by hand."],"tags":["python","json","validation","testing"],"backgroundTag":null,"analyzedSha":"a38d04c3d5c298c851dbe5e6ee1965ee3de42cb5","analyzedAt":"2026-08-14T18:51:02.321Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}