nextlevelbuilder/ui-ux-pro-max-skill · error · SystemExit
Invalid JSON file {path}: {error}
Error message
Invalid JSON file {path}: {error} What it means
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.
Source
Thrown at scripts/evaluate-relevance.py:31
FIXTURE_DIR = RUNTIME_DIR / "tests/fixtures"
sys.path.insert(0, str(RUNTIME_DIR))
sys.path.insert(0, str(ROOT / "scripts"))
from core import (AVAILABLE_STACKS, CSV_CONFIG, DATA_DIR, STACK_CONFIG,
search, search_stack) # noqa: E402
from design_system import DesignSystemGenerator, _palette_is_dark # noqa: E402
from relevance_metrics import (REQUIRED_METRICS, check_thresholds, grades_for_results, ndcg_at_k,
precision_at_k, reciprocal_rank, validate_fixture,
validate_manifest) # noqa: E402
def load_json(path):
def reject_constant(value):
raise ValueError(f"non-RFC JSON numeric constant: {value}")
try:
return json.loads(path.read_text(encoding="utf-8"), parse_constant=reject_constant)
except (json.JSONDecodeError, OSError, ValueError) as error:
raise SystemExit(f"Invalid JSON file {path}: {error}") from error
def runtime_fingerprint():
paths = [
RUNTIME_DIR / "core.py",
RUNTIME_DIR / "design_system.py",
RUNTIME_DIR / "reasoning_contract.py",
]
paths += sorted(DATA_DIR.rglob("*.csv"))
digest = hashlib.sha256()
for path in paths:
digest.update(path.relative_to(ROOT).as_posix().encode() + b"\0")
digest.update(path.read_bytes() + b"\0")
return digest.hexdigest()
def oracle_fingerprint(cases_path=None):
"""Bind approvals to the judgments and the code that grades them."""View on GitHub (pinned to a38d04c3d5)
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.
Example fix
# before
{"grades": [3, NaN]}
# after
{"grades": [3, null]} Defensive patterns
Strategy: validation
Validate before calling
import json
from pathlib import Path
def strict_load(path: Path):
text = path.read_text(encoding='utf-8-sig') # strips BOM if present
def reject(c):
raise ValueError(f'{c} is not allowed in fixtures')
return json.loads(text, parse_constant=reject)
# fail before evaluation if any input file is bad
strict_load(Path('tests/fixtures/relevance-cases.json')) Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
Related errors
- Invalid relevance fixture:\n- {errors}
- Invalid threshold manifest:\n- {manifest_errors}
- Relevance gate failed:\n- {failures}
- duplicate decision-rule key: {}
- decision rules must be a JSON object
AI-assisted analysis of nextlevelbuilder/ui-ux-pro-max-skill@a38d04c3d5 (2026-08-14).
Data as JSON: /api/errors/1c44c6ce28d62b30.
Report an issue: GitHub.