tooling: report damaged inputs in the script state tools without a traceback #666

Merged
louisdibiasi merged 1 commit from upstream-pr/672 into main 2026-11-22 19:15:02 +00:00
louisdibiasi commented 2026-11-22 18:48:05 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by louisdibiasi on 2026-11-22T18:48:05Z.


Change

tools/script_state_probe.py and tools/script_path_replay.py raise ValueError for a file that is not an RPF9 archive and for a --state / --record-with label that is not ASCII, and OSError for a missing archive. The command lines did not catch them, so each ended in a traceback with exit status 1. sgd5_effects.py, texture_descriptors.py and resource_root.py report the same errors as <archive>: <message>. This catches OSError and ValueError around the archive read and the label hash and reports them the same way. Only input handling is wrapped; the replay's own consistency checks keep their traceback.

Independent problem, no linked issue.

Verification

Commit under test: f429a11 on 58dfa51, Windows 11, Python 3.12.10.

Base vs this branch (python -B tools/<tool> <archive> ..., synthetic files):

Command Base This branch
script_state_probe.py empty.bin ValueError: Expected an RPF9 archive traceback, exit 1 <path>\empty.bin: Expected an RPF9 archive, exit 1
script_state_probe.py text.bin same traceback one-line message
script_state_probe.py missing.bin FileNotFoundError traceback <path>: [Errno 2] No such file or directory: ...
script_state_probe.py hdr.bin --state café UnicodeEncodeError: 'ascii' codec can't encode character '\xe9' traceback <path>: 'ascii' codec can't encode character '\xe9' ...
script_path_replay.py empty.bin --host h.dll --record-with anchor path ValueError traceback one-line message
script_path_replay.py missing.bin ... FileNotFoundError traceback one-line message
script_path_replay.py hdr.bin ... --record-with café UnicodeEncodeError traceback one-line message

New CommandLineTests in tests/script_state_check.py run both tools on an empty file, a non-archive, a missing path and a non-ASCII label, and require exit 1, the file name in the message (for archive errors) and no Traceback.

  • Base: python -B tests/script_state_check.py -> Ran 15 tests ... FAILED (failures=8) (every subtest).
  • This branch: Ran 15 tests ... OK.
  • Host-dependent checks against my dev build still pass: python -B tests/script_path_check.py script_path_host.dll -> OK, python -B tests/script_dispatch_check.py script_path_host.dll -> OK.

Evidence and follow-up

Synthetic bytes only, no archive from a game. The --host argument is never reached in the error cases, so the path tool is tested without the built DLL.

Checklist

  • One reviewable behavior.
  • Exact commands and results above.
  • Negative control: the new checks fail on base.
  • No README/docs change needed.
  • No game files, dumps, links or secrets.

AI-assisted: I used Claude to find the bug and draft the change. I ran the reproductions and tests above myself.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6546281076 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/672). Originally posted by [louisdibiasi](https://github.com/louisdibiasi) on 2026-11-22T18:48:05Z. --- ## Change `tools/script_state_probe.py` and `tools/script_path_replay.py` raise `ValueError` for a file that is not an RPF9 archive and for a `--state` / `--record-with` label that is not ASCII, and `OSError` for a missing archive. The command lines did not catch them, so each ended in a traceback with exit status 1. `sgd5_effects.py`, `texture_descriptors.py` and `resource_root.py` report the same errors as `<archive>: <message>`. This catches `OSError` and `ValueError` around the archive read and the label hash and reports them the same way. Only input handling is wrapped; the replay's own consistency checks keep their traceback. Independent problem, no linked issue. ## Verification Commit under test: f429a11 on 58dfa51, Windows 11, Python 3.12.10. Base vs this branch (`python -B tools/<tool> <archive> ...`, synthetic files): | Command | Base | This branch | |---|---|---| | `script_state_probe.py empty.bin` | `ValueError: Expected an RPF9 archive` traceback, exit 1 | `<path>\empty.bin: Expected an RPF9 archive`, exit 1 | | `script_state_probe.py text.bin` | same traceback | one-line message | | `script_state_probe.py missing.bin` | `FileNotFoundError` traceback | `<path>: [Errno 2] No such file or directory: ...` | | `script_state_probe.py hdr.bin --state café` | `UnicodeEncodeError: 'ascii' codec can't encode character '\xe9'` traceback | `<path>: 'ascii' codec can't encode character '\xe9' ...` | | `script_path_replay.py empty.bin --host h.dll --record-with anchor path` | `ValueError` traceback | one-line message | | `script_path_replay.py missing.bin ...` | `FileNotFoundError` traceback | one-line message | | `script_path_replay.py hdr.bin ... --record-with café` | `UnicodeEncodeError` traceback | one-line message | New `CommandLineTests` in `tests/script_state_check.py` run both tools on an empty file, a non-archive, a missing path and a non-ASCII label, and require exit 1, the file name in the message (for archive errors) and no `Traceback`. - Base: `python -B tests/script_state_check.py` -> `Ran 15 tests ... FAILED (failures=8)` (every subtest). - This branch: `Ran 15 tests ... OK`. - Host-dependent checks against my dev build still pass: `python -B tests/script_path_check.py script_path_host.dll` -> OK, `python -B tests/script_dispatch_check.py script_path_host.dll` -> OK. ## Evidence and follow-up Synthetic bytes only, no archive from a game. The `--host` argument is never reached in the error cases, so the path tool is tested without the built DLL. ## Checklist - [x] One reviewable behavior. - [x] Exact commands and results above. - [x] Negative control: the new checks fail on base. - [x] No README/docs change needed. - [x] No game files, dumps, links or secrets. AI-assisted: I used Claude to find the bug and draft the change. I ran the reproductions and tests above myself.
upstream-sync closed this pull request 2026-11-24 06:44:14 +00:00
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
R0Y00/Xbox2Windows!666
No description provided.