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

Manually merged
github merged 1 commit from gh-pr/1155/head into gh-pr/1155/base 2026-11-26 09:40:40 +00:00
Owner

@⁠Okachamie on GitHub · 2026-11-24 19:18 UTC · original
Okachamie:t3/gallery-explicit-dirs → main · +39 −0 · 2 files · 1 commits · merged 2026-11-24 20:04 UTC

Claimed in the coordination issue as: GALLERY-EXPLICIT-DIRS (#14)

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)
**@⁠Okachamie** on GitHub · 2026-11-24 19:18 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1155) `Okachamie:t3/gallery-explicit-dirs` → `main` · +39 −0 · 2 files · 1 commits · merged 2026-11-24 20:04 UTC Claimed in the coordination issue as: GALLERY-EXPLICIT-DIRS (https://git.gtahub.st/github/ubiquitarianism--leonida/issues/14) ### 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)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:40:37 +00:00
github manually merged commit 804a3419d7 into gh-pr/1155/base 2026-11-26 09:40:40 +00:00
Author
Owner

@⁠abnalstlll-byte on GitHub · 2026-11-24 19:22 UTC · original · approved these changes

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.

**@⁠abnalstlll-byte** on GitHub · 2026-11-24 19:22 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1155#pullrequestreview-6045833492) · **approved these changes** 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.
Author
Owner

@⁠KernelSmoker on GitHub · 2026-11-24 19:22 UTC · original · approved these changes

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.

**@⁠KernelSmoker** on GitHub · 2026-11-24 19:22 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1155#pullrequestreview-6045835190) · **approved these changes** 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.
Author
Owner

@⁠kawaii-shakal on GitHub · 2026-11-24 19:27 UTC · original

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

**@⁠kawaii-shakal** on GitHub · 2026-11-24 19:27 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1155#issuecomment-7142115898) 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
Author
Owner

@⁠QemmHD on GitHub · 2026-11-24 20:04 UTC · original

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).

**@⁠QemmHD** on GitHub · 2026-11-24 20:04 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1155#issuecomment-7143004806) 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).
This discussion has been locked. Commenting is limited to contributors.
No description provided.