make_game: report a stage that raises instead of failing silently (BUILD-STAGES-EXCEPTION-DIAG) #1857

Manually merged
github merged 1 commit from gh-pr/1857/head into gh-pr/1857/base 2026-11-26 10:08:52 +00:00
Owner

@⁠thiefyzheng on GitHub · 2026-11-25 13:18 UTC · original
thiefyzheng:fix/build-stages-exception-diag → main · +68 −3 · 2 files · 1 commits · merged 2026-11-25 17:28 UTC

BUILD-STAGES-EXCEPTION-DIAG

Claimed on #1608 (#1608). Fixes @⁠cheltyi's finding (#1608): run_build_stages' series loop and both wait/final-future handlers catch every Exception assuming fail() already printed, so a stage raising anything else (e.g. a PermissionError from a permission/disk/copy failure) exits 1 with empty stderr — verified against the finding's synthetic repro in both overlap modes.

What

  • A report_unexpected(name, exc) helper inside run_build_stages: skips fail()'s own RuntimeError("stage exited...") sys.exit path, deduplicates per stage, prints ERROR: stage '<name>' failed with an unexpected exception: {exc!r} plus a traceback to stderr — once per build, never duplicated between the wait() and drain handlers.
  • Wired into all three catch sites (series loop, wait(), final drain).

What was run (CPU-only, no game files)

  • python3 -m compileall -q make_game.py — OK.
  • python3 tests/test_leonida_tui.py — 27 tests OK (includes the new UnexpectedStageExceptionTest covering both overlap modes: exit 1, stderr names the stage + exception, exactly one report).
  • python3 -m unittest discover -s tests -p "test_make_game_*.py" — 443 OK, 4 skipped; "test_*stage*" — 166 OK, 1 skipped.
  • Guard check: reverting only make_game.py makes both new tests fail ('shaders' not found in ''); restored, they pass.

Attribution

AI-assisted (GLM 5.3 Flash worker implementation, contributor verification and orchestration).

**@⁠thiefyzheng** on GitHub · 2026-11-25 13:18 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1857) `thiefyzheng:fix/build-stages-exception-diag` → `main` · +68 −3 · 2 files · 1 commits · merged 2026-11-25 17:28 UTC ## BUILD-STAGES-EXCEPTION-DIAG Claimed on #1608 (https://git.gtahub.st/github/ubiquitarianism--leonida/issues/1608). Fixes @⁠cheltyi's finding (https://git.gtahub.st/github/ubiquitarianism--leonida/issues/1608): `run_build_stages`' series loop and both wait/final-future handlers catch every `Exception` assuming `fail()` already printed, so a stage raising anything else (e.g. a `PermissionError` from a permission/disk/copy failure) exits 1 with **empty stderr** — verified against the finding's synthetic repro in both overlap modes. ### What - A `report_unexpected(name, exc)` helper inside `run_build_stages`: skips `fail()`'s own `RuntimeError("stage exited...")` sys.exit path, deduplicates per stage, prints `ERROR: stage '<name>' failed with an unexpected exception: {exc!r}` plus a traceback to stderr — once per build, never duplicated between the wait() and drain handlers. - Wired into all three catch sites (series loop, `wait()`, final drain). ### What was run (CPU-only, no game files) - `python3 -m compileall -q make_game.py` — OK. - `python3 tests/test_leonida_tui.py` — **27 tests OK** (includes the new `UnexpectedStageExceptionTest` covering both overlap modes: exit 1, stderr names the stage + exception, exactly one report). - `python3 -m unittest discover -s tests -p "test_make_game_*.py"` — **443 OK, 4 skipped**; `"test_*stage*"` — **166 OK, 1 skipped**. - Guard check: reverting only `make_game.py` makes both new tests fail (`'shaders' not found in ''`); restored, they pass. ### Attribution AI-assisted (GLM 5.3 Flash worker implementation, contributor verification and orchestration).
A stage that raises outright (not through fail()) was swallowed by the
run_build_stages exception handlers: the build stopped with exit 1 and an
empty stderr, so a permission or copy failure gave no visible cause
(board #1608 comment 7163281819). Report the stage name and the exception
once per stage on stderr from the series loop, the wait handler and the
final drain; fail()'s own diagnostics are unchanged and RuntimeError from
its sys.exit is not re-reported.

Tested: tests/test_leonida_tui.py UnexpectedStageExceptionTest (both
overlap modes, fails without the fix); test_make_game_* and stage suites
pass.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 10:08:51 +00:00
github manually merged commit 93a0f21f49 into gh-pr/1857/base 2026-11-26 10:08:52 +00:00
Author
Owner

@⁠madvillain91 on GitHub · 2026-11-25 13:27 UTC · original · reviewed

Independent Windows 11 26H2 (26300.9711) check at 93a0f21f4 against main 384abe5b0, using CPython 3.12.3 (python -I) and Git for Windows 2.56.0.windows.2. Passed test_leonida_tui.py (27/27 in 0.388s, including both overlap=False and overlap=True unexpected-exception diagnostic tests) and test_text_write_line_endings.py (3/3 in 19.945s), with check_no_game_data.py and compileall clean. Confirmed report_unexpected() skips fail()-wrapped RuntimeErrors, deduplicates across wait() and the final futures drain, and surfaces the failing stage name and traceback on stderr. LGTM.

**@⁠madvillain91** on GitHub · 2026-11-25 13:27 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1857#pullrequestreview-6058462251) · **reviewed** Independent Windows 11 26H2 (26300.9711) check at 93a0f21f4 against main 384abe5b0, using CPython 3.12.3 (python -I) and Git for Windows 2.56.0.windows.2. Passed test_leonida_tui.py (27/27 in 0.388s, including both overlap=False and overlap=True unexpected-exception diagnostic tests) and test_text_write_line_endings.py (3/3 in 19.945s), with check_no_game_data.py and compileall clean. Confirmed report_unexpected() skips fail()-wrapped RuntimeErrors, deduplicates across wait() and the final futures drain, and surfaces the failing stage name and traceback on stderr. LGTM.
Author
Owner

@⁠GeorgiyDemo on GitHub · 2026-11-25 14:21 UTC · original

Tested 93a0f21f4 on Apple M5 Pro (16-core GPU), macOS 26.7.3 (25G342), against main 71a769d7d (build tool; no GPU):

  • pytest 9.2.0 on tests/test_leonida_tui.py: 27 passed (2 warnings) at this head.
  • The same file on main: 2 failed, 25 passed — the stage-raises diagnostic cases are new.
  • Not run: a real stage raising inside a full make_game build; the tests inject the failing stage.

AI-assisted; synthetic fixtures only, no game data.

**@⁠GeorgiyDemo** on GitHub · 2026-11-25 14:21 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1857#issuecomment-7165156322) Tested `93a0f21f4` on Apple M5 Pro (16-core GPU), macOS 26.7.3 (25G342), against `main` `71a769d7d` (build tool; no GPU): - pytest 9.2.0 on `tests/test_leonida_tui.py`: **27 passed** (2 warnings) at this head. - The same file on `main`: **2 failed**, 25 passed — the stage-raises diagnostic cases are new. - Not run: a real stage raising inside a full `make_game` build; the tests inject the failing stage. AI-assisted; synthetic fixtures only, no game data.
Author
Owner

@⁠thiefyzheng on GitHub · 2026-11-25 14:23 UTC · original

@⁠GeorgiyDemo — thank you. Recorded for the merge decision: test_leonida_tui.py is 27/27 at 93a0f21f4 on the native runner, and the same file on main fails exactly the two new stage-raises cases (the guard is real — an external demonstration that the fix, not the test, carries the behavior). Not-run noted: no full make_game build with a genuinely failing stage; that path matches the finding's synthetic repro (PermissionError from a patched stage) which the new tests inject the same way. AI-assisted (orchestrator).

**@⁠thiefyzheng** on GitHub · 2026-11-25 14:23 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1857#issuecomment-7165213202) @⁠GeorgiyDemo — thank you. Recorded for the merge decision: `test_leonida_tui.py` is 27/27 at `93a0f21f4` on the native runner, and the same file on `main` fails exactly the two new stage-raises cases (the guard is real — an external demonstration that the fix, not the test, carries the behavior). Not-run noted: no full `make_game` build with a genuinely failing stage; that path matches the finding's synthetic repro (`PermissionError` from a patched stage) which the new tests inject the same way. AI-assisted (orchestrator).
Author
Owner

@⁠aslan2142 on GitHub · 2026-11-25 17:28 UTC · original

Merged. Thank you, @⁠thiefyzheng. A stage that raises now reports its name and the exception on stderr instead of failing silently.

  • The new tests fail on main and pass here; the docs, line-ending and CI/ctest registration checks pass, and so does the game-data check.
  • Checked on main fe1553456 + 93a0f21f4: the semantic suite passes (490 files, 6,292 tests, 0 files failed); test_leonida_tui pass; the 14 docs and writer tests pass; check_no_game_data.py is clean on the 2 changed files.

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

**@⁠aslan2142** on GitHub · 2026-11-25 17:28 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1857#issuecomment-7169547320) Merged. Thank you, @⁠thiefyzheng. A stage that raises now reports its name and the exception on stderr instead of failing silently. - The new tests fail on `main` and pass here; the docs, line-ending and CI/ctest registration checks pass, and so does the game-data check. - **Checked on `main` `fe1553456` + `93a0f21f4`:** the semantic suite passes (490 files, 6,292 tests, 0 files failed); `test_leonida_tui` pass; the 14 docs and writer tests pass; `check_no_game_data.py` is clean on the 2 changed files. AI-assisted (Claude Code, Claude Opus 5.5).
This discussion has been locked. Commenting is limited to contributors.
No description provided.