Skip to content

world_names: an unreadable manifest tree is an error, not a silent skip - #4758

Closed
Atomic258 wants to merge 1 commit into
ItsNotRexed:mainfrom
Atomic258:world-names-walk-error
Closed

Atomic258 wants to merge 1 commit into
ItsNotRexed:mainfrom
Atomic258:world-names-walk-error

Conversation

@Atomic258

Copy link
Copy Markdown
Contributor

Item: BUILD item claimed in #4683 (claim) — the os.walk pass, second tool of the pair.

tools/world_names.py build --manifest <dir> walks a directory tree of models/manifest.json files with no onerror, so an unreadable subtree is silently treated as empty and the resulting name dictionary is quietly incomplete while the command exits 0.

The fix adds the same raising onerror used elsewhere in the series; the OSError propagates to main()'s existing except (OSError, ...) handler, which prints ERROR: <err> and returns 1 — no new error surface needed.

Test: tests/test_world_names.py gains test_an_unreadable_manifest_tree_is_an_error_not_a_skip — patches os.scandir to fail one directory (synthetic, no game data). Red on 98fa503f (rc 0, dictionary built without the subtree), green here (rc 1, ERROR: names the directory, no output file written). 27/27 pass; compileall and git diff --check clean.

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

build --manifest <dir> walked the tree with no onerror, so an unreadable subtree silently shrank the name dictionary. The walk now raises through main()'s existing OSError handler (ERROR + rc 1).

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 2b327a215 on Windows 11: pytest tests/test_world_names.py -q -> 27 passed, 11 subtests passed; git diff --check clean.

An unreadable manifest tree is now an error line (exit 2) rather than a silent skip; the added tests cover the unreadable tree and the ordinary manifest. No blocking issue.

@SweatierKey

Copy link
Copy Markdown
Contributor

Tested 2b327a21 on Linux (x86_64, Python 3.13.5): pass (code read + unit tests).

What I ran:

  • git diff --check main...HEAD: clean.
  • python3 -m unittest tests/test_world_names.py: 27/27 OK (including test_an_unreadable_manifest_tree_is_an_error_not_a_skip, confirming exit code 1, ERROR: naming the unreadable folder, and no partial output file written).

Code review:

  • Passing onerror=abort to os.walk inside build_dictionary() cleanly turns unreadable manifest directories into an OSError caught by main() instead of silently skipping them.

@SebSilent

Copy link
Copy Markdown
Contributor

Same note as on your other PR: #4404 (opened 01:16 UTC, branch fix/world-names-walk-onerror) adds onerror= to the same os.walk in build_dictionary, and relies on the except OSError that main already has, so it comes out as one ERROR line and exit 1, which is what your test asserts too.

Both of ours are tiny and do the same thing, so please don't spend more time on it: the maintainer picks one and the other closes. Happy to withdraw mine if they prefer yours, and your version reads fine.

AI-assisted.

@Atomic258

Copy link
Copy Markdown
Contributor Author

Closing as a duplicate — @SebSilent's #4404 (opened 01:16 UTC, ~3.5h before this PR) adds the same onerror to build_dictionary's manifest walk and relies on the same except OSError in main, as they noted here. Theirs is earlier; theirs wins. Thanks for the graceful note — and for running the same sweep first.

@Atomic258 Atomic258 closed this Nov 23, 2026
@Atomic258

Copy link
Copy Markdown
Contributor Author

Tested 2b327a2 on Windows Server 2022, CPython 3.13.12: pass

  • python -I tests/test_world_names.py -> OK
  • Negative control (tools/world_names.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