Repository navigation
saves: report excessive JSAV JSON nesting as an input error - #3565
Conversation
|
At The new handling itself works once decoding really overflows. Only the fixture depth is too shallow, and the limit depends on the platform and stack size. Building the fixture deep enough to overflow everywhere (e.g. 100,000+), or deriving the depth from a probe, would keep the test portable. I didn't run it on Windows. AI-assisted (Devin); Linux, Python 3.12.16, no GPU or game files. |
kacper-serewis
left a comment
There was a problem hiding this comment.
On Windows at 5c4bce0, info, verify, diff (both argument orders) and extract returned 2 with a single diagnostic for excessive nesting. Source and pre-existing exports were preserved. An initially absent extraction destination was created empty. All four commands succeeded on a valid synthetic save, which packed byte-identically. Two save suites: 82 passed, one POSIX-only skip. AI-assisted CPU validation.
|
Thanks for the Linux reproduction. Fixed the test fixture in bcc39e5: both parser and real-CLI tests now use 100,000 nested arrays, matching the depth your Linux probe confirmed overflows. The production exception handling is unchanged. I also corrected the matching editable-index fixtures on #2779 (acffe1b), which used the same too-shallow depth. Windows CPython 3.12.10: this branch's 50 tests pass with 1 existing POSIX skip; all combined save changes run 60 tests with 3 platform skips and no failures. The two updated branches merge cleanly with the other open account PRs. Native Linux recheck of the new fixture is welcome; no Linux result is claimed locally. AI-assisted. |
|
Rechecked at |
A properly framed JSAV containing excessively nested JSON currently lets
RecursionErrorescape fromJSONDecoder.raw_decode(). Theinfo,verify,diff, andextractcommands then print tracebacks and exit 1. Normalize that decoder failure to the existing JSAV validation error, so each command reports one error line and exits 2 before changing exports.Claim: #3381 (comment) (new JSAV body nesting error handling item; follow-up to merged #2603).
This is separate from #2779's editable pack index validation. The change adds only
RecursionErrorto the existing JSON-body decoder exception tuple; entry bounds and UTF-8 byte-offset/document-end calculations stay intact.Validation on Windows 11, portable CPython 3.12.10, CPU only:
python -W error::ResourceWarning -I tests/test_saves.py -q: 50 tests, 49 passed and 1 existing POSIX permission skip.python -I tests/test_saves_import_args.py: 1 passed.python -I tests/test_save_keys.py -q: 33 passed.python -I tests/test_text_write_line_endings.py: 2 passed.python -m compileall -q make_game.py tools tests: passed.git diff --check: passed.The depth-100000 fixture is hand-built JSON inside a container generated by the real
build_jsav(). Parser and subprocess CLI checks verify the validation contract; CLI checks also verify the source, prior index and prior block bytes remain intact with no extra exports.Synthetic input only; no game files, GPU/driver validation or C++ runtime changes. AI-assisted with Codex.
Portability correction: Linux CPython 3.12 accepts 6,000 nested arrays, as the reviewer reproduced. Both regression fixtures now use 100,000 levels, which exceeded the decoder limit in the reviewer's Linux probe and also passes the Windows error-path checks. Windows CPython 3.12.10: JSAV branch 50 tests (1 POSIX skip), pack-index branch 40 tests, and the combined save branches 60 tests (3 platform skips), all otherwise passing. A native Linux recheck of the updated fixtures is pending. AI-assisted.