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

Closed
opened 2026-11-26 21:19:04 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/1807
Author: @kirigayakazima
Created: 11/25/2026
Status: ✅ Merged
Merged: 11/25/2026
Merged by: @aslan2142

Base: main ← Head: fix/pal-stages-safety


📝 Commits (1)

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

📊 Changes

2 files changed (+61 additions, -5 deletions)

View changed files

📝 tests/test_pal_stages.py (+51 -0)
📝 tools/pal_stages.py (+10 -5)

📄 Description

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)

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ubiquitarianism/leonida/pull/1807 **Author:** [@kirigayakazima](https://github.com/kirigayakazima) **Created:** 11/25/2026 **Status:** ✅ Merged **Merged:** 11/25/2026 **Merged by:** [@aslan2142](https://github.com/aslan2142) **Base:** `main` ← **Head:** `fix/pal-stages-safety` --- ### 📝 Commits (1) - [`abe47df`](https://github.com/ubiquitarianism/leonida/commit/abe47df11e9292817db3c387be33137cb8935756) tools: handle corrupt XBCH zlib, case-insensitive extensions and index errors in pal_stages.py ### 📊 Changes **2 files changed** (+61 additions, -5 deletions) <details> <summary>View changed files</summary> 📝 `tests/test_pal_stages.py` (+51 -0) 📝 `tools/pal_stages.py` (+10 -5) </details> ### 📄 Description 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) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
4ld0 2026-11-26 21:19:04 +01:00
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
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.

Dependencies

No dependencies set

Reference
starred/leonida#1820
No description provided.