Skip to content

bink_index: the --out overwrite guard must not skip an unlistable folder (BUILD-1445) - #7252

Closed
aslan2142 wants to merge 1 commit into
ItsNotRexed:mainfrom
aslan2142:bink-index-out-onerror
Closed

aslan2142 wants to merge 1 commit into
ItsNotRexed:mainfrom
aslan2142:bink-index-out-onerror

Conversation

@aslan2142

Copy link
Copy Markdown
Contributor

Claimed in the coordination issue as BUILD-1445: #7049 (comment) (released to us by SebSilent). Supersedes #4372: SebSilent's fix (commit 64082b9), rebased onto current main; #4372 conflicts with main.

The bug

The change

  • The --out check's walk uses onerror=_walk_error, so a folder it can't list raises.
  • main() catches the OSError and prints one bink_index: error: cannot read <folder>: <reason> line, then exits 2 before anything is scanned or written.
  • New test test_unlistable_folder_cannot_hide_an_input_from_the_out_check makes os.scandir fail for one folder, so it runs on every platform and also as root. It checks:
    • the exit code is 2;
    • stderr is exactly that one line;
    • the scan is never reached;
    • the input stays byte-identical.
  • The fix and the test are SebSilent's (commit author kept).
  • kapitche and KkelebekK tested and reviewed it on bink_index: fail on an unlistable sub-folder instead of silently skipping its files #4372.

What changed in the rebase

Tests

Linux, Python 3.14.10, synthetic input only.

  • python3 -I tests/test_bink_index.py, 33 tests:
    • With main's tool: 2 failures, the new test and test_a_single_named_file_that_is_not_a_stream_or_rpf_is_refused.
    • On the branch: 1 failure, the same pre-existing test.
  • That remaining failure, and test_report_source_collision.py's test_a_distinct_report_path_still_works, are red on main already. bink_index: one wording for both not-a-stream guards; repair the two tests #6917/#6925 left red #7092 fixes both, so they're left alone here.
  • tests/test_bink_names.py: OK.
  • python3 -I -m compileall -q make_game.py tools tests: clean.
  • tests/test_docs_*.py: 9 of 11 OK. test_docs_cli_flags and test_docs_links fail on docs/dev-tools.md, which this PR doesn't touch, so those failures come from main.
  • No doc lists this check, and no option changed.

Relation to other PRs

Checklist

  • No game data: checked (synthetic files and a mocked os.scandir only)
  • Translator rule: not applicable
  • Fails on main, passes here
  • Commit author kept as SebSilent; my rebase change is noted in the message

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

The guard walks the target to see whether --out names an existing input. Without onerror an unlistable sub-folder was skipped, so an input inside it passed the check and got truncated by the report write (verified on main: rc 0, input replaced). The guard walk now uses the same _walk_error as the scan and reports one error line with exit 2 before anything is scanned or written.

Rebased onto main without the PR's first commit: main's scan walk already
raises through a nested scan_failed, so that helper moves to module level as
_walk_error and both walks use it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@duudiis

duudiis commented Nov 23, 2026

Copy link
Copy Markdown

Tested bf1f813 merged onto main 8575d36 on Windows 11 Pro, Intel i7-14700KF, CPython 3.11.0 (stdlib only for these tests), CPU only: pass.

  • git merge --no-ff refs/pr/7252: clean.
  • python -I tests/test_bink_index.py: main 32 tests, 1 failure; PR 33 tests, 1 failure. The failure is the same pre-existing test_a_single_named_file_that_is_not_a_stream_or_rpf_is_refused (message now says "(KB2)"), which the PR body says bink_index: one wording for both not-a-stream guards; repair the two tests #6917/#6925 left red #7092 fixes.
  • New test against main's tools/bink_index.py (only the tool file swapped back): test_unlistable_folder_cannot_hide_an_input_from_the_out_check fails with "the overwrite guard let the run reach the scan"; passes with the PR's tool.
  • python -I tests/test_bink_names.py: 33 tests, 1 failure on both main and PR (test_unreadable_mount_directory_preserves_the_report, Windows-only: the error prints the path via repr, so backslashes are doubled). Unrelated to this PR.
  • python -I tests/test_report_source_collision.py: 8 tests, 1 failure on both (test_a_distinct_report_path_still_works, pre-existing as noted).
  • python -I tests/test_csv_line_endings.py: OK on both.
  • python -m compileall -q tools/bink_index.py tests/test_bink_index.py: clean.
  • python -I tests/test_text_write_line_endings.py: 1 failure on both main and PR, flagging tools/leonida_tui.py:753 and tools/wave_diff.py:373; the PR adds no text writes.

Review notes:

  • tools/bink_index.py:370-383: the ap.error inside the try raises SystemExit, so the new except OSError does not swallow the existing collision error. The new error line uses the same cannot read <path>: <strerror> format as the other OSError paths in main().
  • Moving the nested scan_failed to module-level _walk_error doesn't change how the scan walk behaves.
  • The test mocks bink.os.scandir, which os.walk uses on 3.11 too, so the test works on Windows and doesn't need chmod or a non-root user.

AI-assisted (Claude Code).

@morodirule

Copy link
Copy Markdown

Tested bf1f813 on Arch Linux, Python 3.14.10, CPU only: targeted pass.

No game files, no GPU. AI-assisted.

@KoertLichtendonk

Copy link
Copy Markdown
Contributor

Coordinator note: this looks like the same change as #4372 by @SebSilent (opened 01:05 UTC, still open). Please compare the two and either close this one or say here what it adds. The maintainer decides which one is merged.

@aslan2142

Copy link
Copy Markdown
Contributor Author

Closing in favour of #4372 by @SebSilent, which was opened first. Thanks @KoertLichtendonk for spotting it.

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

@ne1i

ne1i commented Nov 23, 2026

Copy link
Copy Markdown

Tested bf1f8130 on Linux, CPython 3.14, CPU only, synthetic inputs, merged onto main 867d922f: its own new test passes, but the file stays red and a rebase is needed

  • python -I tests/test_bink_index.py: Ran 33 tests, FAILED (failures=1). On unmodified main the same file is FAILED (failures=1) too: test_a_single_named_file_that_is_not_a_stream_or_rpf_is_refused expects a message without (KB2) while the tool prints it with.
  • With only tools/bink_index.py reverted to main: FAILED (failures=2). The additional failure is this PR's new test, so the new test exercises the change.
  • compileall and scripts/check_no_game_data.py on the changed files: clean.

The agent's reading, which I did not re-derive: this branch predates the wording change of that message, so its tool text and main's test disagree. Rebased onto current main, or together with #8609 / #8077 / #8392 (each turns that expectation green alone, my runs), the file should be green.

Independent check (not the author). Run by an AI agent (DeepSeek V4.1 Flash) and re-run by the orchestrating session (Claude Code) before posting.

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.

5 participants