Repository navigation
first_light: name the file when a manifest.json or index.json read fails - #2602
Conversation
A truncated manifest.json (--check) or carve index.json (--list) died with a json.decoder traceback, a non-UTF-8 file with a UnicodeDecodeError, and a well-formed file of the wrong shape with a TypeError or KeyError, though the tool's other failures are single SystemExit lines. The new load_json guards only the two reads main opens, naming the file and the reason on one line, and checks index entries just on the keys --list prints; choose() and translate() keep their plain reads, which ProjectLeonida#2419 rewrites. tests/test_first_light_bad_json.py drives the CLI over hand-written temp folders, with no package or harness; 8 of its 9 tests fail without the change. The tests sit in their own file (moved there in review) so they don't collide with the open pull requests that extend tests/test_first_light.py. AI-assisted: written by Qwen (model qwen3.8-gx10-claude-compatible). Co-Authored-By: Qwen qwen3.8-gx10-claude-compatible <noreply@qwen.ai>
|
Checked Negative control: with I checked the required keys are compatible with what the tools write: No defect found in the claimed cases (truncated / non-UTF-8 / wrong shape / missing keys, both files). AI-assisted review. |
|
Tested 86b5823 merged onto AI-assisted (Claude Code); runs on my machine. |
New BUILD item, claimed here.
What was wrong
tools/first_light.pyended in a traceback when one of the JSON files in the user's folders was broken:--checkwithout--game<out>/manifest.jsontruncatedjson.decoder.JSONDecodeError--checkwithout--gamemanifest.jsonnot UTF-8UnicodeDecodeError--checkwithout--gamemanifest.jsonan array, or withoutwidth/heightTypeError/KeyErrorinrun_draw--listindex.jsontruncated, not UTF-8, not an array, or an entry withoutstage/nameWhat changed
A small
load_jsonhelper reads those two files inmainand exits with one line naming the file and the reason, like the tool's other exits (--list needs --game,shader not in the carve index). Good input behaves as before.Overlap
Four open pull requests touch this tool, so the change is kept to the two reads in
main:choose()andtranslate()keep their plain reads, which first_light: preserve same-name vertex and pixel shader identities #2419 rewrites.tests/test_first_light_bad_json.py, because first_light: preserve same-name vertex and pixel shader identities #2419 and first_light: handle negative OBJ indices, comments, continuations, and bounds checks in read_obj #2489 both extendtests/test_first_light.py.git merge-treeagainst first_light: preserve same-name vertex and pixel shader identities #2419, first_light: handle negative OBJ indices, comments, continuations, and bounds checks in read_obj #2489, d3d12_xs: console-ABI command lists, upload arena, PC-list fixture path #2490 and First light through the D3D12 layer: the real model and its own translated VS/PS drawn by the device proxy #2001 is clean.Tested
Linux 6.8, Python 3.12.3, CPU only; no GPU, no game files, no built harness.
python -I tests/test_first_light_bad_json.py: 9 tests pass. They run the CLI in a subprocess over hand-written folders in a temporary directory; one of them checks that a well-formed index still lists itsvs/psentries.tools/first_light.pyfrommain, 8 of the 9 fail.python -I tests/test_first_light.py: unchanged (7 tests: 4 pass, 3 skipped withoutLEONIDA_FIRST_LIGHT_DIR).Not covered: the
--checksuccess path past the read, which needs the built harness.AI-assisted: written by Qwen (model qwen3.8-gx10-claude-compatible), reviewed and re-run with Claude Code; the tests were moved to their own file in review.