{"record":{"id":"84a5fb7e13575a13","repo":"affaan-m/ECC","slug":"invalid-json-artifact","errorCode":null,"errorMessage":"invalid JSON artifact","messagePattern":"invalid JSON artifact","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"skills/taste-application/scripts/tasteforge/integration.py","lineNumber":184,"sourceCode":"        raise ValueError(\"application request must be a JSON object\")\n    return value\n\n\ndef _load_json(data: bytes) -> Any:\n    def unique(pairs):\n        result = {}\n        for key, value in pairs:\n            if key in result:\n                raise ValueError(\"duplicate JSON field\")\n            result[key] = value\n        return result\n\n    try:\n        value = json.loads(data, object_pairs_hook=unique)\n        _canonical(value)\n        return value\n    except (UnicodeError, RecursionError) as exc:\n        raise ValueError(\"invalid JSON artifact\") from exc\n\n\ndef _snapshot(baseline: dict) -> dict:\n    _object(baseline, {\"project_file\", \"snapshot_file\", \"project_name\", \"timeline_name\",\n                       \"fps\", \"timeline_range\"})\n    _rate(baseline[\"fps\"])\n    bounds = _range(baseline[\"timeline_range\"])\n    _artifact(baseline[\"project_file\"])\n    snapshot = _artifact(baseline[\"snapshot_file\"], parse_json=True)\n    if not isinstance(snapshot, dict):\n        raise ValueError(\"native snapshot must be an object\")\n    settings = snapshot.get(\"settings\")\n    native_fps = settings.get(\"timelineFrameRate\") if isinstance(settings, dict) else None\n    # Resolve's conventional decimal NTSC labels represent these exact rates.\n    ntsc = {\"23.976\": \"24000/1001\", \"29.97\": \"30000/1001\", \"59.94\": \"60000/1001\"}\n    try:\n        if type(native_fps) not in (str, int, float):\n            raise ValueError(\"native fps missing\")","sourceCodeStart":166,"sourceCodeEnd":202,"githubUrl":"https://github.com/affaan-m/ECC/blob/8321021c54d670126ce3b2969d5deb880b4b0c2a/skills/taste-application/scripts/tasteforge/integration.py#L166-L202","documentation":"_load_json wraps json.loads and a canonicalization pass; if parsing raises UnicodeError (invalid UTF-8/escape sequences) or RecursionError (nesting beyond the interpreter limit), it re-raises as \"invalid JSON artifact\". It signals bytes that cannot be decoded as safe, bounded JSON.","triggerScenarios":"Calling load_application_request or any _artifact(..., parse_json=True) path where the file contains invalid UTF-8 bytes, malformed \\u escapes, or JSON nested deeper than Python's recursion limit (~1000 levels).","commonSituations":"Files saved with a non-UTF-8 encoding (UTF-16, Latin-1); binary files accidentally given a .json extension; truncated downloads; machine-generated deeply nested JSON.","solutions":["Re-encode the file as UTF-8 without BOM (`iconv -f UTF-16 -t UTF-8 in.json > out.json`).","Validate the file with `python -m json.tool file.json` to see the exact decode error.","Check for accidental binary content (`file snapshot.json` should say 'JSON' or 'ASCII text').","Flatten or split pathologically nested JSON (depth > ~1000) before loading."],"exampleFix":"// before\n$ file snapshot.json -> data (UTF-16)\n\n// after\n$ iconv -f UTF-16LE -t UTF-8 snapshot.json > snapshot.utf8.json","handlingStrategy":"validation","validationCode":"def check_decodable(path):\n    raw = open(path, \"rb\").read()\n    try:\n        raw.decode(\"utf-8\")\n    except UnicodeDecodeError as e:\n        raise ValueError(f\"{path}: not UTF-8: {e}\")","typeGuard":null,"tryCatchPattern":"try:\n    request = load_application_request(path)\nexcept ValueError as exc:\n    if \"invalid JSON artifact\" in str(exc):\n        print(f\"{path}: re-encode as UTF-8 and validate with python -m json.tool\")\n    raise","preventionTips":["Save/export all JSON as UTF-8 without BOM.","Run `python -m json.tool` on generated artifacts before use.","Never rename binary files to .json.","Keep JSON nesting shallow (< a few hundred levels)."],"tags":["json","encoding","parse"],"backgroundTag":"json-parse-error","analyzedSha":"8321021c54d670126ce3b2969d5deb880b4b0c2a","analyzedAt":"2026-09-16T10:08:13.343Z","contentChangedAt":"2026-09-16T10:08:13.343Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}