tools: handle corrupt XBCH zlib, case-insensitive extensions and index errors in pal_stages.py #1807

Merged
kirigayakazima merged 1 commit from upstream-pr/1807 into main 2026-11-25 17:29:48 +00:00
kirigayakazima commented 2026-11-25 12:21:07 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by kirigayakazima on 2026-11-25T12:21:07Z.


Claimed in the coordination issue as: PAL-STAGES-ZLIB-ERROR-AND-CASE-EXTENSIONS (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7162211163)

What and why

  • Catch zlib.error in tools/pal_stages.py's blob_rows() so a DXBC container with a corrupt XBCH zlib stream is recorded as an error row instead of aborting the entire directory run with an unhandled traceback.
  • Match .fssm and .dxbc extensions case-insensitively in files_of() and deduplicate bare FSSM vs container stems with os.path.normcase.
  • Guard fssm_header.stage_index() in main() against RecursionError on malformed/deeply nested index.json.
  • Add synthetic regression tests in tests/test_pal_stages.py.

Tested

  • python -I tests/test_pal_stages.py -v -> Ran 21 tests in 0.391s, OK (verified in a detached upstream/main worktree that all three new tests fail before the fix: FAILED (failures=1, errors=2)).
  • python -I tests/test_ci_registration.py -> Ran 16 tests in 4.462s, OK.
  • python -I tests/test_text_write_line_endings.py -> Ran 3 tests in 12.612s, OK.
  • python -I scripts/check_no_game_data.py tools/pal_stages.py tests/test_pal_stages.py -> exit 0.
  • python -I -m compileall -q tools/pal_stages.py tests/test_pal_stages.py and git diff --check -> clean.

GPUs tested: n/a (CPU/stdlib Python tests on Windows 11 x64)

AI-assisted: yes

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • 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)
<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5491218396 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1807). Originally posted by [kirigayakazima](https://github.com/kirigayakazima) on 2026-11-25T12:21:07Z. --- Claimed in the coordination issue as: PAL-STAGES-ZLIB-ERROR-AND-CASE-EXTENSIONS (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7162211163) ### What and why - Catch `zlib.error` in `tools/pal_stages.py`'s `blob_rows()` so a DXBC container with a corrupt `XBCH` zlib stream is recorded as an error row instead of aborting the entire directory run with an unhandled traceback. - Match `.fssm` and `.dxbc` extensions case-insensitively in `files_of()` and deduplicate bare FSSM vs container stems with `os.path.normcase`. - Guard `fssm_header.stage_index()` in `main()` against `RecursionError` on malformed/deeply nested `index.json`. - Add synthetic regression tests in `tests/test_pal_stages.py`. ### Tested - `python -I tests/test_pal_stages.py -v` -> `Ran 21 tests in 0.391s`, `OK` (verified in a detached `upstream/main` worktree that all three new tests fail before the fix: `FAILED (failures=1, errors=2)`). - `python -I tests/test_ci_registration.py` -> `Ran 16 tests in 4.462s`, `OK`. - `python -I tests/test_text_write_line_endings.py` -> `Ran 3 tests in 12.612s`, `OK`. - `python -I scripts/check_no_game_data.py tools/pal_stages.py tests/test_pal_stages.py` -> exit `0`. - `python -I -m compileall -q tools/pal_stages.py tests/test_pal_stages.py` and `git diff --check` -> clean. GPUs tested: n/a (CPU/stdlib Python tests on Windows 11 x64) AI-assisted: yes ### Checklist - [x] Based on current main and merges cleanly (a conflicting pull request is labeled `needs rebase`). - [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)
madvillain91 commented 2026-11-25 12:58:18 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by madvillain91 on 2026-11-25T12:58:18Z.

Review: COMMENTED


Independent Windows 11 26H2 (26300.9711) check at abe47df11 against main 98c2f7777 (PR base 0d80bc5df), using CPython 3.12.3 (python -I) and Git for Windows 2.56.0.windows.2. All 40 tests passed across test_pal_stages.py (21/21 in 0.589s), test_ci_registration.py (16/16 in 7.577s), and test_text_write_line_endings.py (3/3 in 16.880s), with check_no_game_data.py and compileall clean. Verified Windows os.path.normcase stem deduplication for mixed-case .FSSM/.DXBC extensions, graceful zlib.error row reporting on corrupt XBCH payloads, and RecursionError handling around fssm_header.stage_index(). LGTM.

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6058036171 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1807#pullrequestreview-6058036171). Originally posted by [madvillain91](https://github.com/madvillain91) on 2026-11-25T12:58:18Z. **Review:** COMMENTED --- Independent Windows 11 26H2 (26300.9711) check at abe47df11 against main 98c2f7777 (PR base 0d80bc5df), using CPython 3.12.3 (python -I) and Git for Windows 2.56.0.windows.2. All 40 tests passed across test_pal_stages.py (21/21 in 0.589s), test_ci_registration.py (16/16 in 7.577s), and test_text_write_line_endings.py (3/3 in 16.880s), with check_no_game_data.py and compileall clean. Verified Windows os.path.normcase stem deduplication for mixed-case .FSSM/.DXBC extensions, graceful zlib.error row reporting on corrupt XBCH payloads, and RecursionError handling around fssm_header.stage_index(). LGTM.
DeadlyChirp commented 2026-11-25 15:52:53 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by DeadlyChirp on 2026-11-25T15:52:53Z.


Tested on Windows 11, Python 3.12.10, with this PR merged onto current upstream main.

python -m pytest -q tests/test_pal_stages.py:

  • PR: 21 passed. main: 18 passed. The new tests pass on Windows.

(AI-assisted test run; output checked by hand.)

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7167394937 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1807#issuecomment-7167394937). Originally posted by [DeadlyChirp](https://github.com/DeadlyChirp) on 2026-11-25T15:52:53Z. --- Tested on Windows 11, Python 3.12.10, with this PR merged onto current upstream main. `python -m pytest -q tests/test_pal_stages.py`: - PR: 21 passed. main: 18 passed. The new tests pass on Windows. (AI-assisted test run; output checked by hand.)
MSedgeMC commented 2026-11-25 17:24:24 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MSedgeMC on 2026-11-25T17:24:24Z.

Review: APPROVED


Verified on the PR branch: python3 -m unittest tests.test_pal_stages -v -> 21 tests OK, including new cases for corrupt XBCH zlib producing an error row instead of crashing, case-insensitive extension handling, and deduplication. The tool now reports bad payloads as data rather than aborting the whole scan. Python-only, no game data.

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6062013127 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1807#pullrequestreview-6062013127). Originally posted by [MSedgeMC](https://github.com/MSedgeMC) on 2026-11-25T17:24:24Z. **Review:** APPROVED --- Verified on the PR branch: python3 -m unittest tests.test_pal_stages -v -> 21 tests OK, including new cases for corrupt XBCH zlib producing an error row instead of crashing, case-insensitive extension handling, and deduplication. The tool now reports bad payloads as data rather than aborting the whole scan. Python-only, no game data.
aslan2142 commented 2026-11-25 17:29:52 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by aslan2142 on 2026-11-25T17:29:52Z.


Merged. Thank you, @kirigayakazima. A corrupt XBCH stream no longer aborts the whole directory run, and extensions match case-insensitively.

  • 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 aeec1ddc6 + abe47df11: the semantic suite passes (490 files, 6,292 tests, 0 files failed); test_pal_stages 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).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7169587893 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1807#issuecomment-7169587893). Originally posted by [aslan2142](https://github.com/aslan2142) on 2026-11-25T17:29:52Z. --- Merged. Thank you, @kirigayakazima. A corrupt XBCH stream no longer aborts the whole directory run, and extensions match case-insensitively. - 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` `aeec1ddc6` + `abe47df11`:** the semantic suite passes (490 files, 6,292 tests, 0 files failed); `test_pal_stages` 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).
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!1807
No description provided.