Skip to content

vertex_types: an unreadable input directory is an error, not a silent skip - #4757

Closed
Atomic258 wants to merge 1 commit into
ItsNotRexed:mainfrom
Atomic258:vertex-types-walk-error
Closed

Atomic258 wants to merge 1 commit into
ItsNotRexed:mainfrom
Atomic258:vertex-types-walk-error

Conversation

@Atomic258

Copy link
Copy Markdown
Contributor

Item: BUILD item claimed in #4683 (claim) — the os.walk pass.

tools/vertex_types.py collects .rpf archives from each user-supplied input directory with os.walk and no onerror, so os.walk treats an unreadable subtree as empty: archives under it never reach the census and the run still exits 0 with plausible-looking totals.

The fix walks with an onerror that re-raises and catches OSError around the collection loop, reporting the file's usual error: <input>: <err> + rc 2 — the same surface per-archive read failures already get at the scan loop.

Test: tests/test_vertex_types.py gains test_an_unreadable_directory_is_an_error_not_a_skip — patches os.scandir to fail one directory (synthetic, no game data). Red on 98fa503f (rc 0, silent skip), green here (rc 2, one error: line naming the directory). The existing walk-order test's os.walk stub now tolerates the onerror kwarg. 43/43 pass; compileall and git diff --check clean.

AI-assisted (Devin). No GPU needed — CPU-only tool.

… skip

os.walk dropped an unreadable subtree, so .rpf archives under it never reached the census and the run still exited 0. Walk with an onerror that raises and surface it as the file's usual error + rc 2.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>

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

Ran this at 3f7957fa7 on Windows 11: pytest tests/test_vertex_types.py -q -> 43 passed, 8 subtests passed; git diff --check clean.

An input directory that cannot be listed is now an error (exit 2) instead of an empty type set; the added tests cover the unreadable directory and the ordinary path. No blocking issue.

@SebSilent

Copy link
Copy Markdown
Contributor

Heads up, no contest intended: #4417 (opened 01:20 UTC, branch fix/vertex-types-walk-onerror) is the same fix on the same line, os.walk(p, onerror=...) with main turning the OSError into one error: line and exit 2. Mine already has a code read from a reviewer, so the maintainer will probably keep that one and ask mine or yours to close, whichever they prefer. If it is yours, say the word and I will withdraw #4417 rather than have two people's review time spent on it.

Your def walk(path, **_kwargs) tweak in the existing ordering test is a tidier way to let the mock absorb the new kwarg than my def walk(path, onerror=None), worth keeping if yours lands. Mine adds a second test that forces os.scandir to raise, because the chmod-based one self-skips on Windows and when CI runs as root.

AI-assisted.

@kapitche

Copy link
Copy Markdown
Contributor

Tested 3f7957f merged with main 98fa503 on Linux (WSL2), Python 3.12.16, CPU only: pass

  • python -I tests/test_vertex_types.py: 43 tests OK.
  • Negative control: with tools/vertex_types.py restored from main, 1 failure, the new test_an_unreadable_directory_is_an_error_not_a_skip (the other 42 still pass); restored the PR file afterwards.
  • Read the diff: os.walk(p, onerror=abort) re-raises, main prints a single error: <dir>: <exc> line and returns 2; the existing walk mock in test_directory_scan_uses_stable_archive_order was updated to accept the new keyword. No issues found.
  • Linux only; the test mocks os.scandir, so it does not depend on real permissions.

@Atomic258

Copy link
Copy Markdown
Contributor Author

Closing as a duplicate — @SebSilent's #4417 (opened 01:20 UTC, ~3.5h before this PR) already adds the same raising onerror to the vertex_types input-directory walk with equivalent os.scandir-patch test coverage. Theirs is earlier; theirs wins. My collision check only scanned a truncated recent-PR list and missed it — noted for future claims.

@Atomic258 Atomic258 closed this Nov 23, 2026
@Atomic258

Copy link
Copy Markdown
Contributor Author

Tested 3f7957f on Windows Server 2022, CPython 3.13.12: pass

  • python -I tests/test_vertex_types.py -> OK (Ran 43)
  • Negative control (tools/vertex_types.py swapped to upstream/main): FAILED (failures=1)

git diff --check clean; python -m compileall -q exit 0. No game files, no GPU. AI-assisted (Devin).

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