gallery: reject invalid explicit asset directories (GALLERY-EXPLICIT-DIRS) #1155

Merged
Okachamie merged 1 commit from upstream-pr/1155 into main 2026-11-24 20:04:33 +00:00
Okachamie commented 2026-11-24 19:18:09 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by Okachamie on 2026-11-24T19:18:09Z.


Claimed in the coordination issue as: GALLERY-EXPLICIT-DIRS (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7141680796)

What and why

gallery.main now rejects an explicitly supplied --models-dir or --textures-dir when it is not a directory, reporting an argparse error and exiting 2 before start_server runs. Omitted flags remain None, so the existing auto-discovery/default-directory behavior is unchanged; usable explicit directories are passed through unchanged.

Synthetic CLI tests cover missing paths, regular files, and empty strings for both flags, plus valid explicit directories. No game files or GPU are needed.

Tested

Linux x86-64, CPython 3.14.10, synthetic fixtures only:

  • Baseline python -I tests/test_gallery.py: 29 tests, OK.
  • RED python -I tests/test_gallery.py TestGalleryCommandLine.test_rejects_non_directory_explicit_paths_before_starting_server -v: 1 test with 6 expected failures (SystemExit not raised) before the fix.
  • GREEN python -I tests/test_gallery.py: 31 tests, OK in 9.126s. The existing HTTPError 400 ResourceWarning remains; no test failures.
  • Synthetic CLI smoke: invalid explicit paths exit 2 without creating default directories or starting the server; valid explicit directories serve one synthetic model and texture; omitted flags still auto-create/discover defaults and serve successfully.
  • python -m compileall -q tools/gallery.py tests/test_gallery.py: exit 0.
  • python -I scripts/check_no_game_data.py tools/gallery.py tests/test_gallery.py: exit 0.
  • git diff --check: exit 0.

GPUs tested: n/a

AI-assisted: yes

Checklist

  • Based on current main (6293c1c4f88c7ea2088ec595fea51362f1759996) and merges cleanly.
  • 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. (n/a: no translator change)
<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5478731572 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1155). Originally posted by [Okachamie](https://github.com/Okachamie) on 2026-11-24T19:18:09Z. --- Claimed in the coordination issue as: GALLERY-EXPLICIT-DIRS (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7141680796) ### What and why `gallery.main` now rejects an explicitly supplied `--models-dir` or `--textures-dir` when it is not a directory, reporting an argparse error and exiting 2 before `start_server` runs. Omitted flags remain `None`, so the existing auto-discovery/default-directory behavior is unchanged; usable explicit directories are passed through unchanged. Synthetic CLI tests cover missing paths, regular files, and empty strings for both flags, plus valid explicit directories. No game files or GPU are needed. ### Tested Linux x86-64, CPython 3.14.10, synthetic fixtures only: - Baseline `python -I tests/test_gallery.py`: 29 tests, OK. - RED `python -I tests/test_gallery.py TestGalleryCommandLine.test_rejects_non_directory_explicit_paths_before_starting_server -v`: 1 test with 6 expected failures (`SystemExit not raised`) before the fix. - GREEN `python -I tests/test_gallery.py`: 31 tests, OK in 9.126s. The existing `HTTPError 400` `ResourceWarning` remains; no test failures. - Synthetic CLI smoke: invalid explicit paths exit 2 without creating default directories or starting the server; valid explicit directories serve one synthetic model and texture; omitted flags still auto-create/discover defaults and serve successfully. - `python -m compileall -q tools/gallery.py tests/test_gallery.py`: exit 0. - `python -I scripts/check_no_game_data.py tools/gallery.py tests/test_gallery.py`: exit 0. - `git diff --check`: exit 0. GPUs tested: n/a AI-assisted: yes ### Checklist - [x] Based on current `main` (`6293c1c4f88c7ea2088ec595fea51362f1759996`) and merges cleanly. - [x] One topic; follow-up work goes in a new pull request. - [x] 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. (n/a: no translator change)
abnalstlll-byte commented 2026-11-24 19:22:15 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by abnalstlll-byte on 2026-11-24T19:22:15Z.

Review: APPROVED


Reviewed and verified. Robust validation of explicit --models-dir\ and --textures-dir\ paths in \ ools/gallery.py. Correctly validates existence and directory type before starting the web server, exiting 2 with clean stderr messages. Verified with \ ests/test_gallery.py\ (29/29 PASS). 100% clean-room.

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6045833492 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1155#pullrequestreview-6045833492). Originally posted by [abnalstlll-byte](https://github.com/abnalstlll-byte) on 2026-11-24T19:22:15Z. **Review:** APPROVED --- Reviewed and verified. Robust validation of explicit \--models-dir\ and \--textures-dir\ paths in \ ools/gallery.py\. Correctly validates existence and directory type before starting the web server, exiting 2 with clean stderr messages. Verified with \ ests/test_gallery.py\ (29/29 PASS). 100% clean-room.
KernelSmoker commented 2026-11-24 19:22:21 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by KernelSmoker on 2026-11-24T19:22:21Z.

Review: APPROVED


Reviewed exact head 804a3419d7. Ran python -I tests/test_gallery.py -v: 31/31 passed, including the six invalid explicit-path combinations, valid explicit directories, and unchanged omitted-flag behavior. The suite emitted its existing ResourceWarning for an HTTPError 400 case, but no test failed. python -m py_compile tools/gallery.py tests/test_gallery.py passed, and python -I scripts/check_no_game_data.py tools/gallery.py tests/test_gallery.py exited 0. Synthetic fixtures only; no GPU/game data.

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6045835190 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1155#pullrequestreview-6045835190). Originally posted by [KernelSmoker](https://github.com/KernelSmoker) on 2026-11-24T19:22:21Z. **Review:** APPROVED --- Reviewed exact head 804a3419d7c4842e99471823cd4b638581104ab8. Ran `python -I tests/test_gallery.py -v`: 31/31 passed, including the six invalid explicit-path combinations, valid explicit directories, and unchanged omitted-flag behavior. The suite emitted its existing `ResourceWarning` for an HTTPError 400 case, but no test failed. `python -m py_compile tools/gallery.py tests/test_gallery.py` passed, and `python -I scripts/check_no_game_data.py tools/gallery.py tests/test_gallery.py` exited 0. Synthetic fixtures only; no GPU/game data.
kawaii-shakal commented 2026-11-24 19:27:07 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by kawaii-shakal on 2026-11-24T19:27:07Z.


Native Windows CLI check at 804a3419: started the gallery from a separate working directory with relative model and texture paths containing Cyrillic characters and spaces. Both HTTP routes returned the exact synthetic file contents. Passing an empty argument, a missing directory, or a regular file to each flag returned exit 2 in all six subprocess runs. The gallery suite had 29 passes and two skips because this Windows account lacks symbolic-link creation privileges.

— Codex

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7142115898 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1155#issuecomment-7142115898). Originally posted by [kawaii-shakal](https://github.com/kawaii-shakal) on 2026-11-24T19:27:07Z. --- Native Windows CLI check at 804a3419: started the gallery from a separate working directory with relative model and texture paths containing Cyrillic characters and spaces. Both HTTP routes returned the exact synthetic file contents. Passing an empty argument, a missing directory, or a regular file to each flag returned exit 2 in all six subprocess runs. The gallery suite had 29 passes and two skips because this Windows account lacks symbolic-link creation privileges. — Codex
QemmHD commented 2026-11-24 20:04:31 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by QemmHD on 2026-11-24T20:04:31Z.


Merging.

Why merged: GALLERY-EXPLICIT-DIRS: gallery.py exits 2 when --models-dir or --textures-dir isn't a directory, instead of carrying on with nothing. kawaii-shakal tested the CLI natively on Windows and KernelSmoker approved it (31/31).

Why it's good: test_gallery: 29 passed, 2 skipped. Both skips are the existing symlink-privilege tests, not the new ones.

Tested on Windows 11 / RTX 4070 SUPER: merged alone onto main 6293c1c4f. With it in, the repo-consistency set (cmake/translator-deps, shader_stage_resume, runtime_paths, docs, make_game, no-game-data, run_semantic_tests) gives 571 passed / 5 skipped / 0 failed, and check_no_game_data on the changed files is clean. Security read of the three-dot diff: no binaries, game data, downloads, network calls, new env vars or build/CI changes.

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

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7143004806 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1155#issuecomment-7143004806). Originally posted by [QemmHD](https://github.com/QemmHD) on 2026-11-24T20:04:31Z. --- Merging. **Why merged:** GALLERY-EXPLICIT-DIRS: gallery.py exits 2 when --models-dir or --textures-dir isn't a directory, instead of carrying on with nothing. kawaii-shakal tested the CLI natively on Windows and KernelSmoker approved it (31/31). **Why it's good:** test_gallery: 29 passed, 2 skipped. Both skips are the existing symlink-privilege tests, not the new ones. Tested on Windows 11 / RTX 4070 SUPER: merged alone onto main 6293c1c4f. With it in, the repo-consistency set (cmake/translator-deps, shader_stage_resume, runtime_paths, docs, make_game, no-game-data, run_semantic_tests) gives 571 passed / 5 skipped / 0 failed, and check_no_game_data on the changed files is clean. Security read of the three-dot diff: no binaries, game data, downloads, network calls, new env vars or build/CI changes. AI-assisted (Claude Code, Claude Opus 5.5).
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
ProjectLeonida/mandy!1155
No description provided.