[PR #1584] world_drawable_lookup: validate hex keys, archetype u32 fields, window budget, and deep JSON (WORLD-DRAWABLE-LOOKUP-VALIDATION) #1603

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

📋 Pull Request Information

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

Base: main ← Head: fix/world-drawable-lookup-validation


📝 Commits (1)

  • ed2affd world_drawable_lookup: validate hex keys, archetype u32 fields, window budget, and deep JSON

📊 Changes

2 files changed (+126 additions, -10 deletions)

View changed files

📝 tests/test_world_drawable_lookup.py (+89 -0)
📝 tools/world_drawable_lookup.py (+37 -10)

📄 Description

Item: WORLD-DRAWABLE-LOOKUP-VALIDATION (unclaimed — coordination issue #14 is at GitHub's 2,500-comment cap with no successor open issue yet, and 0 open PRs touch tools/world_drawable_lookup.py).

Summary

  • Strictly parse placement key values as unsigned 64-bit hex strings ([0-9a-fA-F]+, < 2^64) so signed ("-1", "+1"), underscore-separated ("1_2"), 0x-prefixed, padded, or overflowing keys are counted as missing_or_invalid_key rather than entering wanted (where "-1" formatted as "-000000000000001").
  • Validate archetype row name, asset_name, and asset_type fields as optional unsigned 32-bit integers (type(v) is int), preventing Python's True == 1 collision from matching asset_type == 1 (.#ft) and avoiding raw TypeError: unhashable type on malformed rows.
  • Require type(budget) is int in export_window() so bool (True == 1), float (1.5), and non-numeric values raise ValueError instead of being accepted or raising TypeError.
  • Reject whitespace-only summary.archive strings, catch RecursionError in report_rows() and main(argv=None), enforce allow_nan=False on JSON output, and return exit code 0.

Verification

  • python3 -W error -I tests/test_world_drawable_lookup.py -v: 6/6 passed.
  • python3 -I tests/test_text_write_line_endings.py: 3/3 passed.
  • python3 -I scripts/check_no_game_data.py tools/world_drawable_lookup.py tests/test_world_drawable_lookup.py: passed.
  • python3 -m compileall -q tools/world_drawable_lookup.py tests/test_world_drawable_lookup.py: passed.
  • Mutation check (running the new test suite against unpatched main:tools/world_drawable_lookup.py): failures=7, errors=3 across all 4 new regression tests.

AI-assisted: yes
GPUs tested: none (CPU-only Python tool; synthetic fixtures 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/1584 **Author:** [@IlyassRS3](https://github.com/IlyassRS3) **Created:** 11/25/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/world-drawable-lookup-validation` --- ### 📝 Commits (1) - [`ed2affd`](https://github.com/ubiquitarianism/leonida/commit/ed2affda718d7bdf8bf433f3d1cbc201bd443494) world_drawable_lookup: validate hex keys, archetype u32 fields, window budget, and deep JSON ### 📊 Changes **2 files changed** (+126 additions, -10 deletions) <details> <summary>View changed files</summary> 📝 `tests/test_world_drawable_lookup.py` (+89 -0) 📝 `tools/world_drawable_lookup.py` (+37 -10) </details> ### 📄 Description Item: `WORLD-DRAWABLE-LOOKUP-VALIDATION` (unclaimed — coordination issue #14 is at GitHub's 2,500-comment cap with no successor open issue yet, and 0 open PRs touch `tools/world_drawable_lookup.py`). ### Summary - Strictly parse placement `key` values as unsigned 64-bit hex strings (`[0-9a-fA-F]+`, `< 2^64`) so signed (`"-1"`, `"+1"`), underscore-separated (`"1_2"`), `0x`-prefixed, padded, or overflowing keys are counted as `missing_or_invalid_key` rather than entering `wanted` (where `"-1"` formatted as `"-000000000000001"`). - Validate archetype row `name`, `asset_name`, and `asset_type` fields as optional unsigned 32-bit integers (`type(v) is int`), preventing Python's `True == 1` collision from matching `asset_type == 1` (`.#ft`) and avoiding raw `TypeError: unhashable type` on malformed rows. - Require `type(budget) is int` in `export_window()` so `bool` (`True == 1`), `float` (`1.5`), and non-numeric values raise `ValueError` instead of being accepted or raising `TypeError`. - Reject whitespace-only `summary.archive` strings, catch `RecursionError` in `report_rows()` and `main(argv=None)`, enforce `allow_nan=False` on JSON output, and return exit code `0`. ### Verification - `python3 -W error -I tests/test_world_drawable_lookup.py -v`: 6/6 passed. - `python3 -I tests/test_text_write_line_endings.py`: 3/3 passed. - `python3 -I scripts/check_no_game_data.py tools/world_drawable_lookup.py tests/test_world_drawable_lookup.py`: passed. - `python3 -m compileall -q tools/world_drawable_lookup.py tests/test_world_drawable_lookup.py`: passed. - Mutation check (running the new test suite against unpatched `main:tools/world_drawable_lookup.py`): `failures=7, errors=3` across all 4 new regression tests. AI-assisted: yes GPUs tested: none (CPU-only Python tool; synthetic fixtures 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#1603
No description provided.