Skip to content

gbuffer_census, navmesh_cell_fit, root_spill_census: a wrong input is one ERROR line, not a traceback - #952

Merged
aslan2142 merged 1 commit into
ProjectLeonida:mainfrom
barkodr:fix/census-tools-wrong-input
Dec 1, 2026
Merged

aslan2142 merged 1 commit into
ProjectLeonida:mainfrom
barkodr:fix/census-tools-wrong-input

Conversation

@barkodr

@barkodr barkodr commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

Claimed in the coordination issue as: claiming: tools/gbuffer_census.py, navmesh_cell_fit.py and root_spill_census.py stop with a traceback on a wrong input (a file for the carve folder, a non-RPF archive, a non-UTF-8 index); print one ERROR line and exit 2 like the other tools. Tools only. AI-assisted.

What and why

  • tools/gbuffer_census.py given a file instead of a shader_carve folder stopped with NotADirectoryError, and its main() never returned an exit code.
  • tools/navmesh_cell_fit.py given a file that is not an RPF archive raised the right ValueError message, but as a traceback.
  • tools/root_spill_census.py given a JSON index that is not UTF-8, or a folder, stopped with UnicodeDecodeError or IsADirectoryError.

All three now follow tools/navmesh_nodes.py: except (OSError, ValueError) prints ERROR: ... and exits 2.

Tested

On macOS 26.6.2 with Python 3.12.16, from the checkout root with python -I: tests/test_gbuffer_census.py, tests/test_navmesh_cell_fit.py, tests/test_root_spill_census.py, tests/test_tool_startup.py, tests/test_text_write_line_endings.py and tests/test_docs_python_deps.py pass. On Ubuntu 26.04 (WSL2) with Python 3.14.4 the first five of those pass; test_docs_python_deps.py was not run there. Each new wrong-input test fails against the tool on main and passes with the fix. Not run on real game files; the normal output is unchanged. tests/test_tool_stdout_encoding.py fails on this branch as it does on main, on both systems, listing only tools/native_pso_hashes.py, which this pull request does not touch.

GPUs tested: none (no GPU code changed)

AI-assisted: yes

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed.

@KernelSmoker KernelSmoker 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.

Verified on exact head 40f2414d47df58ad0dd578edf41d085ced0ada55. Focused Linux tests passed: test_gbuffer_census.py 4/4, test_navmesh_cell_fit.py 5/5, test_root_spill_census.py 21/21, test_tool_startup.py 2/2, test_text_write_line_endings.py 3/3, and test_docs_python_deps.py 3/3 (38 total). Python compile, check_no_game_data.py, and git diff --check passed. Synthetic wrong inputs only; no game data/GPU. The reported unrelated test_tool_stdout_encoding.py failure was not treated as part of this change and was not independently rerun.

@kurrutako

Copy link
Copy Markdown
Contributor

Tested on Windows 11, Python 3.14.6, head 40f2414.

  • The four test files: 32 passed.

  • I ran each tool by hand on wrong input:

    • a file given as the carve folder;
    • a non-UTF-8 index;
    • a zero-filled .rpf;
    • a folder given as the index;
    • a non-JSON --carve.

    Each case gives one ERROR: line and exit 2. On main each one is a traceback with exit 1.

  • Minor: on Windows, a folder given as the index reports "[Errno 13] Permission denied" rather than "is a directory".

Merging current main conflicts only in tools/navmesh_cell_fit.py: main (#2446) added an --out guard inside if a.common:. Moving those two lines into the new try resolves it. After that the tests give 34 passed, and the manual checks are unchanged.

AI-assisted (Claude Code)

@aslan2142 aslan2142 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.

Reviewed against current main: normalizing wrong-input handling to a single ERROR line in tools/gbuffer_census.py, tools/navmesh_cell_fit.py, and tools/root_spill_census.py looks good, but this branch currently conflicts with main. Please rebase onto current main so CI runs cleanly.

(AI-assisted review.)

@aslan2142
aslan2142 force-pushed the fix/census-tools-wrong-input branch from 40f2414 to 51f94c8 Compare December 1, 2026 17:44
@aslan2142

Copy link
Copy Markdown
Collaborator

Rebased onto current main (d2a564b66, new head 51f94c885), preserving the --out overwrite guard in tools/navmesh_cell_fit.py inside the new try block (AI-assisted).

Local Linux verification (synthetic inputs, no game data):

  • scripts/check_no_game_data.py: pass
  • git diff --check origin/main..HEAD: pass
  • python3 -m compileall -q make_game.py tools tests: pass
  • tests/test_gbuffer_census.py (4/4), tests/test_navmesh_cell_fit.py (7/7), tests/test_root_spill_census.py (21/21), tests/test_tool_startup.py (2/2), tests/test_tool_stdout_encoding.py (4/4), tests/test_text_write_line_endings.py (3/3), tests/test_docs_python_deps.py (3/3): 44/44 pass

@aslan2142
aslan2142 merged commit dcda41f into ProjectLeonida:main Dec 1, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs rebase Conflicts with the base branch: rebase it on main

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants