[PR #1603] tex_export: validate dimensions and paths, clean partial DDS, write export_log atomically (TEX-EXPORT-GUARDS-AND-ATOMIC-LOG) #1619

Open
opened 2026-11-26 20:21:52 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/1603
Author: @IlyassRS3
Created: 11/25/2026
Status: 🔄 Open

Base: main ← Head: fix/tex-export-guards-and-atomic-log


📝 Commits (1)

  • d0a0a36 tex_export: validate dimensions and archive/fmt_name paths, clean partial DDS, write export_log atomically

📊 Changes

2 files changed (+195 additions, -11 deletions)

View changed files

📝 tests/test_tex_export.py (+110 -0)
📝 tools/tex_export.py (+85 -11)

📄 Description

Item: TEX-EXPORT-GUARDS-AND-ATOMIC-LOG (unclaimed — coordination issue #14 is at GitHub's 2,500-comment cap with no successor open issue yet, and 0 open PRs touch tools/tex_export.py).

Summary

  • Validate positive non-bool integer dimensions in detile_offsets() and export_one(), and reject empty, absolute, or ..-traversing archive paths and path-separator fmt_name values before opening blobs or creating output subdirectories.
  • Remove partially written .dds files if write() fails with OSError in export_one(), matching the existing PNG partial-file cleanup.
  • Reject empty or whitespace-only index/carve/out arguments in main(argv=None) (preventing " " directory creation in cwd), and catch RecursionError when loading textures_index.json.
  • Publish export_log.json atomically via file_mode.published_mode + replace_retry.replace with allow_nan=False (preserving existing logs on write failure and handling non-regular targets), keeping the exact compact JSON format.

Verification

  • python3 -W error -m pytest tests/test_tex_export.py -q: 144 passed.
  • python3 -I tests/test_text_write_line_endings.py: 3/3 passed.
  • python3 -I scripts/check_no_game_data.py tools/tex_export.py tests/test_tex_export.py: passed.
  • python3 -m compileall -q tools/tex_export.py tests/test_tex_export.py: passed.
  • Mutation check (running tests/test_tex_export.py against unpatched main:tools/tex_export.py): 10 failed, 134 passed across all new regression tests.

AI-assisted: yes
GPUs tested: none (CPU-only Python texture exporter; synthetic swizzle equations and blobs only, no game data)


🔄 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/1603 **Author:** [@IlyassRS3](https://github.com/IlyassRS3) **Created:** 11/25/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/tex-export-guards-and-atomic-log` --- ### 📝 Commits (1) - [`d0a0a36`](https://github.com/ubiquitarianism/leonida/commit/d0a0a366192bb439dbdf7f251ee8de157eba5929) tex_export: validate dimensions and archive/fmt_name paths, clean partial DDS, write export_log atomically ### 📊 Changes **2 files changed** (+195 additions, -11 deletions) <details> <summary>View changed files</summary> 📝 `tests/test_tex_export.py` (+110 -0) 📝 `tools/tex_export.py` (+85 -11) </details> ### 📄 Description Item: `TEX-EXPORT-GUARDS-AND-ATOMIC-LOG` (unclaimed — coordination issue #14 is at GitHub's 2,500-comment cap with no successor open issue yet, and 0 open PRs touch `tools/tex_export.py`). ### Summary - Validate positive non-bool integer dimensions in `detile_offsets()` and `export_one()`, and reject empty, absolute, or `..`-traversing `archive` paths and path-separator `fmt_name` values before opening blobs or creating output subdirectories. - Remove partially written `.dds` files if `write()` fails with `OSError` in `export_one()`, matching the existing PNG partial-file cleanup. - Reject empty or whitespace-only `index`/`carve`/`out` arguments in `main(argv=None)` (preventing `" "` directory creation in `cwd`), and catch `RecursionError` when loading `textures_index.json`. - Publish `export_log.json` atomically via `file_mode.published_mode` + `replace_retry.replace` with `allow_nan=False` (preserving existing logs on write failure and handling non-regular targets), keeping the exact compact JSON format. ### Verification - `python3 -W error -m pytest tests/test_tex_export.py -q`: 144 passed. - `python3 -I tests/test_text_write_line_endings.py`: 3/3 passed. - `python3 -I scripts/check_no_game_data.py tools/tex_export.py tests/test_tex_export.py`: passed. - `python3 -m compileall -q tools/tex_export.py tests/test_tex_export.py`: passed. - Mutation check (running `tests/test_tex_export.py` against unpatched `main:tools/tex_export.py`): 10 failed, 134 passed across all new regression tests. AI-assisted: yes GPUs tested: none (CPU-only Python texture exporter; synthetic swizzle equations and blobs only, no game data) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
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#1619
No description provided.