Skip to content

root_spill_census: an unreadable or malformed index is one ERROR line and exit 2 - #6105

Open
Koro4e wants to merge 1 commit into
ItsNotRexed:mainfrom
Koro4e:root-spill-index-guards
Open

Koro4e wants to merge 1 commit into
ItsNotRexed:mainfrom
Koro4e:root-spill-index-guards

Conversation

@Koro4e

@Koro4e Koro4e commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Claimed in the coordination issue as this finding, from DeepSeek3's report.

What and why

tools/root_spill_census.py opened the translator index (and the optional --carve index) with a bare open + json.load, so a missing index ended in a FileNotFoundError traceback and a malformed one in a json.JSONDecodeError traceback, both exit 1. Both reads are now inside a try that prints one ERROR: cannot read ... line and exits 2, as the sibling report tools (tools/d3d12_iid_scan.py and the ones #5733/#5735 gave the same shape) do.

Two commits: the tool, then the tests.

Tested

  • python -m pytest tests/test_root_spill_census.py -q: 12 passed (11 pre-existing + test_an_unreadable_or_malformed_index_is_one_error_line, which covers the missing index, the malformed index, and the --carve file getting the same treatment).
  • Negative control: with main's tools/root_spill_census.py the new test fails; with this branch all 12 pass.
  • Manual: --json naming the temp directory continues to work through argparse as before (untouched).

Windows 11, Python 3.12.10, CPU only. No game files.

Checklist

  • No game data, keys or decryption (CONTRIBUTING.md).
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (No translator changes.)

@memorypressure

Copy link
Copy Markdown

Verified at your head on main 561b65a: compileall clean, test_root_spill_census 12/12 (re-run), and your new test fails on a clean main checkout — the guard is load-bearing. The ERROR wording and exit 2 match the sibling d3d12_iid_scan.py:158. One coverage nit: the third sub-check hands a malformed index plus a missing --carve, so it exits 2 via the index branch and the carve try is never executed by the test — pass good.json as the index to cover that path (a manual carve run does give the claimed single ERROR line + exit 2). Checks pending. AI-assisted: yes. Tested on Linux (RTX 5080 host, CPU-only run).

@Koro4e

Koro4e commented Nov 23, 2026

Copy link
Copy Markdown
Contributor Author

Rebased onto current main (8575d36) - the conflicts with the round-44 merge were resolved locally, tests pass locally (package-gated skips unchanged). Head updated on the fork.

@Koro4e
Koro4e force-pushed the root-spill-index-guards branch from 2de5d6f to 9105dc1 Compare November 23, 2026 17:07
@skorex

skorex commented Nov 23, 2026

Copy link
Copy Markdown

Duplicate of #5712

#5712 makes the same change and was opened earlier (#7429 is duplicates too). Topic: root_spill_census: unreadable index = one error line.

Suggest closing this PR in favour of #5712, and porting anything this one adds that #5712 lacks there.

@bobcatchris

Copy link
Copy Markdown
Contributor

Two gaps this PR leaves, measured on main 7541333a0 with synthetic files only (no game data). Both are small; I had them on #7429, which I am closing in favour of this one.

1. RecursionError is not caught. except (OSError, ValueError) covers the missing file, a permission error, non-UTF-8 bytes (UnicodeDecodeError) and malformed JSON (JSONDecodeError), but json.load on a deeply nested file raises RecursionError, which is neither of those. A file made of "[" * 100000 + "]" * 100000 still gives:

RecursionError: maximum recursion depth exceeded while decoding a JSON array from a unicode string

except (OSError, ValueError, RecursionError) with a line like ERROR: cannot read <path>: nested too deeply to read closes it. The other tools that read JSON hit this too; see #7107's wave64_halves and #7249.

2. Three read cases are untested. The new test covers a missing index, {bad, and a missing --carve. Also worth pinning, all exit 2 with an ERROR: cannot read line, no Traceback, and no report written: non-UTF-8 bytes (e.g. b"��GARBAGEÿ" * 40), a zero-byte file, and the nested file above.

Nothing else: the BOM handling, the --json guards and every verdict stay as main has them. Happy to review the follow-up. AI-assisted.

@sds-228 sds-228 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-reviewed at the current head. Both index reads now produce one ERROR line and exit 2 instead of a traceback.

CPU-only verification: 19/19 tests pass with the change; the pre-change tool fails the new case. The missing-carve branch is covered manually rather than by the automated subtest. No game data.

AI-assisted (OpenCode).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants