hashdict: report unreadable --extra files cleanly (HASHDICT-EXTRA-READ-ERROR) #1071

Merged
leonida/mandy
j-weiner merged 1 commit from fix/hashdict-extra-read-error into main 2026-11-24 23:21:53 +00:00

Pull request successfully merged and closed

j-weiner commented 2026-11-24 17:46:07 +00:00

Claimed in the coordination issue as: HASHDICT-EXTRA-READ-ERROR (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7139578822)

What and why

When hashdict.py reads a regular file supplied through --extra, an OSError from opening or reading it escaped as a traceback. The tool already reports unreadable extra directories cleanly. This catches the file case, prints one ERROR line, exits 2, and leaves an existing --out unchanged. The regression uses a synthetic PermissionError; no game files are needed.

Tested

  • python -I -B tests/test_hashdict.py — 42 passed, 1 skipped.
  • python -I -B tests/test_tool_startup.py — 2 passed.
  • python -I -B tests/test_text_write_line_endings.py — 3 passed.
  • python -m compileall -q tools/hashdict.py tests/test_hashdict.py — passed.
  • python -I scripts/check_no_game_data.py tools/hashdict.py tests/test_hashdict.py — passed.
  • python -I tools/hashdict.py --help — passed.
  • git diff --check — passed.
  • The new regression reproduced the uncaught PermissionError before the fix; it now verifies the one-line diagnostic, exit code 2, and preserved output.

GPUs tested: n/a (CPU-only synthetic tests).

AI-assisted: yes.

Checklist

  • Based on current main and merges cleanly.
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys, or decryption.
  • New translator rule: not applicable.
Claimed in the coordination issue as: HASHDICT-EXTRA-READ-ERROR (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7139578822) ### What and why When `hashdict.py` reads a regular file supplied through `--extra`, an `OSError` from opening or reading it escaped as a traceback. The tool already reports unreadable extra directories cleanly. This catches the file case, prints one `ERROR` line, exits 2, and leaves an existing `--out` unchanged. The regression uses a synthetic `PermissionError`; no game files are needed. ### Tested - `python -I -B tests/test_hashdict.py` — 42 passed, 1 skipped. - `python -I -B tests/test_tool_startup.py` — 2 passed. - `python -I -B tests/test_text_write_line_endings.py` — 3 passed. - `python -m compileall -q tools/hashdict.py tests/test_hashdict.py` — passed. - `python -I scripts/check_no_game_data.py tools/hashdict.py tests/test_hashdict.py` — passed. - `python -I tools/hashdict.py --help` — passed. - `git diff --check` — passed. - The new regression reproduced the uncaught `PermissionError` before the fix; it now verifies the one-line diagnostic, exit code 2, and preserved output. GPUs tested: n/a (CPU-only synthetic tests). AI-assisted: yes. ### Checklist - [x] Based on current `main` and merges cleanly. - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys, or decryption. - [x] New translator rule: not applicable.
KernelSmoker approved these changes 2026-11-24 18:03:47 +00:00
KernelSmoker left a comment

The synthetic regression exercises the unreadable regular-file path, checks the one-line diagnostic and exit code 2, and confirms the existing output dictionary is preserved. The catch is limited to opening/reading the --extra file and returns before output serialization. On exact head 4c1eae00557c3a2920b6480ceb3076f95dae1d92, independent checks passed: hashdict 43/43, tool startup 2/2, line endings 3/3; --help, no-game-data, diff, and merge-tree checks also passed. CPU-only synthetic tests; no game data.

The synthetic regression exercises the unreadable regular-file path, checks the one-line diagnostic and exit code 2, and confirms the existing output dictionary is preserved. The catch is limited to opening/reading the --extra file and returns before output serialization. On exact head 4c1eae00557c3a2920b6480ceb3076f95dae1d92, independent checks passed: hashdict 43/43, tool startup 2/2, line endings 3/3; --help, no-game-data, diff, and merge-tree checks also passed. CPU-only synthetic tests; no game data.
QemmHD commented 2026-11-24 23:21:50 +00:00

Merging.

Why merged: HASHDICT-EXTRA-READ-ERROR: an unreadable --extra file gives one ERROR line and exit 2, and an existing --out file is left intact instead of being clobbered. KernelSmoker approved it.

Why it's good: test_hashdict: 42 passed, 1 skipped.

Tested on Windows 11 / RTX 4070 SUPER: merged alone onto main 0f98d193c. With it in, the repo-consistency set (cmake/translator-deps, shader_stage_resume, runtime_paths, docs, make_game, no-game-data, run_semantic_tests, ctest_registration) gives 578 passed / 5 skipped / 0 failed, and check_no_game_data on the changed files is clean. git merge-tree against current main: no conflicts. Security read of the three-dot diff: no binaries, game data, downloads, network calls or CI changes.

AI-assisted (Claude Code, Claude Opus 5.5).

Merging. **Why merged:** HASHDICT-EXTRA-READ-ERROR: an unreadable --extra file gives one ERROR line and exit 2, and an existing --out file is left intact instead of being clobbered. KernelSmoker approved it. **Why it's good:** test_hashdict: 42 passed, 1 skipped. Tested on Windows 11 / RTX 4070 SUPER: merged alone onto main 0f98d193c. With it in, the repo-consistency set (cmake/translator-deps, shader_stage_resume, runtime_paths, docs, make_game, no-game-data, run_semantic_tests, ctest_registration) gives 578 passed / 5 skipped / 0 failed, and check_no_game_data on the changed files is clean. git merge-tree against current main: no conflicts. Security read of the three-dot diff: no binaries, game data, downloads, network calls or CI changes. AI-assisted (Claude Code, Claude Opus 5.5).
Sign in to join this conversation.
No description provided.