Skip to content

tools: missing inputs are one ERROR line and exit 2 in five more tools - #6701

Merged
shayderrr merged 2 commits into
ItsNotRexed:mainfrom
liang-kai-shui:build-missing-input-more
Nov 23, 2026
Merged

shayderrr merged 2 commits into
ItsNotRexed:mainfrom
liang-kai-shui:build-missing-input-more

Conversation

@liang-kai-shui

Copy link
Copy Markdown
Contributor

Claimed in the coordination issue as: #6603 (comment)

Five tools regressed (or never had) the BUILD-1046 contract: a nonexistent positional input must be one ERROR: line and exit 2.

tool before
tools/d3d12_guid_sites.py FileNotFoundError traceback, exit 1
tools/gamedata_blobs.py error: <path>: no such file or folder, exit 1
tools/navmesh_cell_fit.py traceback from navmesh_decode._scan_rpf, exit 1
tools/psin_psch.py error: <path>, exit 1
tools/root_spill_census.py FileNotFoundError traceback, exit 1

Each now checks the input exists before doing any work and prints ERROR: cannot read <path>: ..., exit 2. tests/test_missing_input_exit_codes.py gains the five tools (it runs every listed tool with a nonexistent path and asserts exit 2, exactly one ERROR: line naming the path, no traceback).

Tested: python -I tests/test_missing_input_exit_codes.py -> 2 tests OK (17 tools); compileall clean; git diff --check clean. Two commits (fixes, test list). No game data.

AI-assisted.

@AsgerCode

Copy link
Copy Markdown

Tested 1e8665e on Windows 11 (NTFS), Python 3.12.10 (CPU only, no GPU, no game files): fail, the PR breaks the existing tests/test_gamedata_blobs.py.

What I ran:

  • python -I tests/test_missing_input_exit_codes.py: 2 tests, OK.
  • Negative control (merge base 1cc6e3c1 versions of the five tools): 5 subtest failures, one for each new tool (exit 1, with a traceback or an error: line).
  • Each tool's own test file at the PR head: test_d3d12_guid_sites 7 OK, test_navmesh_cell_fit 4 OK, test_psin_psch 3 OK, test_root_spill_census 18 OK, test_gamedata_blobs 7 tests, 1 failure. That file passes on the merge base.
  • Merge with current main (f25ba44e, 135 commits ahead): clean. main changed tools/d3d12_guid_sites.py in d3d12_guid_sites: protect inputs from JSON output #6931. On the merged tree, the same test_gamedata_blobs failure remains and the other files pass (test_d3d12_guid_sites 8 OK).

The failure:

python -I tests/test_gamedata_blobs.py
FAIL: test_missing_file_names_what_is_wrong (BadCarveIndexTest)
AssertionError: 2 != 1 : ERROR: cannot read ...\nope.rpf: no such file or folder

BadCarveIndexTest.assert_one_error expects exit 1 and a line that starts with error:. This PR changes the missing-target case of gamedata_blobs.py to exit 2 and ERROR: on purpose, but the old test was not updated. Suggested fix: let assert_one_error take the expected code and prefix (default 1, "error:"), and pass 2, "ERROR:" in test_missing_file_names_what_is_wrong. You can also delete that test, because test_missing_input_exit_codes.py now covers the case.

Edge cases I ran by hand (empty folder or a non-PE file made by hand):

input PR head merge base
d3d12_guid_sites.py <folder> exit 2, ERROR: cannot read <folder>: no such file exit 1, PermissionError traceback
d3d12_guid_sites.py junk.bin missing.exe scans junk.bin (prints skipped), then exit 2 traceback
root_spill_census.py <folder> exit 1, PermissionError traceback same
root_spill_census.py <folder> --carve missing.json exit 2, ERROR: cannot read missing.json exit 1, traceback

Nits, none blocking:

  1. d3d12_guid_sites.py: the folder case says "no such file", but the folder exists ("not a file" is correct). The check is also inside the loop, so earlier images are scanned and printed before the exit 2. "Checks the input exists before doing any work" is true only for one image.
  2. root_spill_census.py: os.path.exists lets a folder through as the index, and open() then fails with a traceback. os.path.isfile catches that case too.

Overlap with other open PRs that put the same guard in the same tools:

AI-assisted (Claude Code).

@shayderrr shayderrr left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Summary

Five tools (d3d12_guid_sites.py, gamedata_blobs.py, navmesh_cell_fit.py, psin_psch.py, root_spill_census.py) now check that their input path exists and return a clear exit-2 error instead of a traceback. The missing-input exit-code test list is extended to cover them.

Why merge

Missing inputs are routine CLI mistakes, and a consistent ERROR: cannot read ... with exit 2 keeps batch runs predictable. The shared test ensures each tool maintains that contract.

Verdict: Approve

@shayderrr

Copy link
Copy Markdown
Collaborator

Summary

Five tools (d3d12_guid_sites.py, gamedata_blobs.py, navmesh_cell_fit.py, psin_psch.py, root_spill_census.py) now check that their input path exists and return a clear exit-2 error instead of a traceback. The missing-input exit-code test list is extended to cover them.

Why merge

Missing inputs are routine CLI mistakes, and a consistent ERROR: cannot read ... with exit 2 keeps batch runs predictable. The shared test ensures each tool maintains that contract.

Verdict: Approve

@shayderrr
shayderrr merged commit 22037f7 into ItsNotRexed:main Nov 23, 2026
0 of 2 checks passed
natterman12 pushed a commit to natterman12/Leonida that referenced this pull request Nov 23, 2026
…Rexed#6701

ItsNotRexed#6701 made gamedata_blobs report a missing target as one "ERROR: cannot
read ..." line with exit 2; this test still expected the older "error:"
line and exit 1.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DgEAspvdc9tB3AHyEa2Ef8
@memorypressure

Copy link
Copy Markdown

Post-merge heads-up from a routine first-arrival sweep against main dde82f2: your ERROR-line/exit-2 convention change did not reach tools/gamedata_blobs.py — the tool prints "ERROR: cannot read ..." with return 2 at :365, but tests/test_gamedata_blobs.py BadCarveIndexTest.test_missing_file_names_what_is_wrong (:290) still expects "error:" + exit 1. Reproduced on clean main: Ran 7, FAILED (failures=1). One-line fix either direction — update the test's expectations or keep the tool's message aligned — main has been red on this file since 22037f7 landed. AI-assisted: yes. Tested on Linux (RTX 5080 host, CPU-only run).

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.

4 participants