fix(tools): report deeply nested JSON as invalid input and run the reserved-name archive test #12266

Merged
MarcZX10 merged 5 commits from upstream-pr/12266 into main 2026-10-28 11:30:17 +00:00
MarcZX10 commented 2026-10-28 06:05:44 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-28T06:05:44Z.


What

Three defects in repository tooling. One commit each; the two Python fixes have a test commit each:

  • tools/hw-oracle/compare_results.py: read_report passes the file to json.loads, and a report nested a few hundred thousand levels deep raises RecursionError, which main does not catch. The command ended in a traceback with exit code 1, the code the tool documents as "different outputs", so a corrupt file looked like a hardware difference. It now raises a ValueError naming the file, and main reports it with exit code 2 like every other invalid report.
  • tools/import_audit.py: read_registry and read_needed_registry catch OSError, UnicodeDecodeError and JSONDecodeError but not RecursionError. main returns 2 for an AuditError and 1 for missing imports, so a deeply nested registry ended in a traceback with exit code 1 and looked like a failed import audit. RecursionError is now reported as an AuditError (exit code 2).
  • tools/test_web.py launched archive-root, archive-windows and archive.test but not demo/web/tests/archive-reserved.test.mjs, which covers the superscript Windows device names added with 3397e873bc. No workflow, script or CTest entry referenced it, so a regression in validPath for those names went unnoticed. It runs next to the other archive tests now. I did not run it (it needs a web build and the zip library download).

Tested

python3 -m unittest test_compare_results in tools/hw-oracle (12 tests) and python3 -m unittest test_import_audit in tools/tests (157 tests, 1 skipped) pass. Each of the two new tests fails against main's version of its script. tools/check_conventions.py --base upstream/main and git diff --check pass.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5046010378 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/12266). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-28T06:05:44Z. --- ### What Three defects in repository tooling. One commit each; the two Python fixes have a test commit each: - `tools/hw-oracle/compare_results.py`: `read_report` passes the file to `json.loads`, and a report nested a few hundred thousand levels deep raises `RecursionError`, which `main` does not catch. The command ended in a traceback with exit code 1, the code the tool documents as "different outputs", so a corrupt file looked like a hardware difference. It now raises a `ValueError` naming the file, and `main` reports it with exit code 2 like every other invalid report. - `tools/import_audit.py`: `read_registry` and `read_needed_registry` catch `OSError`, `UnicodeDecodeError` and `JSONDecodeError` but not `RecursionError`. `main` returns 2 for an `AuditError` and 1 for missing imports, so a deeply nested registry ended in a traceback with exit code 1 and looked like a failed import audit. `RecursionError` is now reported as an `AuditError` (exit code 2). - `tools/test_web.py` launched `archive-root`, `archive-windows` and `archive.test` but not `demo/web/tests/archive-reserved.test.mjs`, which covers the superscript Windows device names added with 3397e873bc. No workflow, script or CTest entry referenced it, so a regression in `validPath` for those names went unnoticed. It runs next to the other archive tests now. I did not run it (it needs a web build and the zip library download). ### Tested `python3 -m unittest test_compare_results` in `tools/hw-oracle` (12 tests) and `python3 -m unittest test_import_audit` in `tools/tests` (157 tests, 1 skipped) pass. Each of the two new tests fails against `main`'s version of its script. `tools/check_conventions.py --base upstream/main` and `git diff --check` pass. ### Checklist - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
rooklz commented 2026-10-28 11:22:36 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by rooklz on 2026-10-28T11:22:36Z.

Review: APPROVED


Review of 70cd9c91c2, macOS arm64, run locally on this machine. The head merges cleanly onto main 3a40945e62.

JSON depth (does the fixture trigger on every supported Python?) json.loads("[" * n):

Python n=20000 n=200000
3.9.6 RecursionError RecursionError
3.13.1 RecursionError RecursionError
3.14.8 JSONDecodeError RecursionError ("Stack overflow")
3.15.1 JSONDecodeError RecursionError ("Stack overflow")

At 20000 the input is caught on 3.14+ already. 200000 hits the uncaught path on all four versions, so the fixture depth is the right choice.

Python fixes

  • With the head checked out, test_compare_results (12 tests) and test_import_audit (157 tests, 1 skipped) pass on 3.9.6, 3.13 and 3.14.
  • With only the two scripts set back to main (3.9.6), each module fails exactly one test: the new one.
  • Mutants, all killed: dropping RecursionError from read_registry only, dropping it from read_needed_registry only, and changing the nested too deeply message. The second half of the import_audit test does its job.
  • The three json.loads call sites in these two files are all covered now.

archive-reserved.test.mjs wiring (the body says this was not run, so I ran it). build_web.copy_sources copies demo/web as-is, so I put a scratch <build>/web copy together and fetched the pinned zip.js:

  • Head: node demo/web/tests/archive-reserved.test.mjs <build>/web exits 0 on Node 26.4.0.
  • When I set the scratch archive.mjs back to the regex from before 3397e873bc (com[1-9]|lpt[1-9]), it fails with AssertionError: Missing expected exception., so the newly wired test does catch the regression it was written for.
  • The whole tools/test_web.py --build <scratch> run stops later, at archive.test.mjs, because it needs the real native/relinker_wasm.mjs. That is expected without a wasm build and is not part of this change.
  • Non-blocking: web-tests.yml triggers on tools/test_web.py but never runs it; it only runs archive-root plus node --test for 4 files. test_web.py runs only in release.yml, so the reserved-name test will run at release time, not on PRs. Adding a step to web-tests.yml the way archive-root is wired would catch it per PR. That could be a follow-up.

Gates (merged tree) check_conventions --base upstream/main passes. Relinker-only build 270/270, ctest 378/378. pr_overlap reports only #6171 and #7454 as not comparable (both conflicting) on the import_audit files; this diff adds lines to the except tuples and one test, so I don't see a topical overlap.

Approving.

AI-assisted: yes

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5681817333 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/12266#pullrequestreview-5681817333). Originally posted by [rooklz](https://github.com/rooklz) on 2026-10-28T11:22:36Z. **Review:** APPROVED --- Review of `70cd9c91c2`, macOS arm64, run locally on this machine. The head merges cleanly onto `main` `3a40945e62`. **JSON depth (does the fixture trigger on every supported Python?)** `json.loads("[" * n)`: | Python | n=20000 | n=200000 | |---|---|---| | 3.9.6 | RecursionError | RecursionError | | 3.13.1 | RecursionError | RecursionError | | 3.14.8 | JSONDecodeError | RecursionError ("Stack overflow") | | 3.15.1 | JSONDecodeError | RecursionError ("Stack overflow") | At 20000 the input is caught on 3.14+ already. 200000 hits the uncaught path on all four versions, so the fixture depth is the right choice. **Python fixes** - With the head checked out, `test_compare_results` (12 tests) and `test_import_audit` (157 tests, 1 skipped) pass on 3.9.6, 3.13 and 3.14. - With only the two scripts set back to `main` (3.9.6), each module fails exactly one test: the new one. - Mutants, all killed: dropping `RecursionError` from `read_registry` only, dropping it from `read_needed_registry` only, and changing the `nested too deeply` message. The second half of the import_audit test does its job. - The three `json.loads` call sites in these two files are all covered now. **`archive-reserved.test.mjs` wiring** (the body says this was not run, so I ran it). `build_web.copy_sources` copies `demo/web` as-is, so I put a scratch `<build>/web` copy together and fetched the pinned zip.js: - Head: `node demo/web/tests/archive-reserved.test.mjs <build>/web` exits 0 on Node 26.4.0. - When I set the scratch `archive.mjs` back to the regex from before 3397e873bc (`com[1-9]|lpt[1-9]`), it fails with `AssertionError: Missing expected exception.`, so the newly wired test does catch the regression it was written for. - The whole `tools/test_web.py --build <scratch>` run stops later, at `archive.test.mjs`, because it needs the real `native/relinker_wasm.mjs`. That is expected without a wasm build and is not part of this change. - Non-blocking: `web-tests.yml` triggers on `tools/test_web.py` but never runs it; it only runs `archive-root` plus `node --test` for 4 files. `test_web.py` runs only in `release.yml`, so the reserved-name test will run at release time, not on PRs. Adding a step to `web-tests.yml` the way `archive-root` is wired would catch it per PR. That could be a follow-up. **Gates (merged tree)** `check_conventions --base upstream/main` passes. Relinker-only build 270/270, `ctest` 378/378. `pr_overlap` reports only #6171 and #7454 as not comparable (both conflicting) on the import_audit files; this diff adds lines to the except tuples and one test, so I don't see a topical overlap. Approving. AI-assisted: yes
THEMANnt commented 2026-10-28 11:26:52 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by THEMANnt on 2026-10-28T11:26:52Z.

Review: APPROVED


Reviewed 70cd9c91c2afdb3348e644b83772346c7058acfc — approve. Deeply nested import registries are reported as invalid input instead of escaping as RecursionError. The Windows reserved-name archive case is enabled as part of this patch.

Windows/Python 3.11: head test_import_audit.py: 154 passed, 3 skipped (157 total); base test_import_audit.py: 153 passed, 3 skipped (156 total). The new nested-registry case fails against old production with the reproduced RecursionError. This control establishes the parsing fix; it does not imply that every platform-only archive case executed. Full command/output evidence is retained locally. Hosted CI and mergeability are rechecked before publication. No game or full product execution is claimed.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5681862813 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/12266#pullrequestreview-5681862813). Originally posted by [THEMANnt](https://github.com/THEMANnt) on 2026-10-28T11:26:52Z. **Review:** APPROVED --- Reviewed `70cd9c91c2afdb3348e644b83772346c7058acfc` — approve. Deeply nested import registries are reported as invalid input instead of escaping as RecursionError. The Windows reserved-name archive case is enabled as part of this patch. Windows/Python 3.11: head test_import_audit.py: 154 passed, 3 skipped (157 total); base test_import_audit.py: 153 passed, 3 skipped (156 total). The new nested-registry case fails against old production with the reproduced RecursionError. This control establishes the parsing fix; it does not imply that every platform-only archive case executed. Full command/output evidence is retained locally. Hosted CI and mergeability are rechecked before publication. No game or full product execution is claimed.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!12266
No description provided.