Skip to content

tex_headers: reject bool and non-int inputs in decode_etpf_chunk_pages and compact_surface_layout - #8774

Open
cristianvaz wants to merge 1 commit into
ItsNotRexed:mainfrom
cristianvaz:fix/tex-headers-bool-validation
Open

cristianvaz wants to merge 1 commit into
ItsNotRexed:mainfrom
cristianvaz:fix/tex-headers-bool-validation

Conversation

@cristianvaz

Copy link
Copy Markdown

Claimed in #8683: #8683 (comment)

Summary

Rejects bool (which satisfies isinstance(..., int) in Python) and non-integer parameters in two layout/chunk helpers in tools/tex_headers.py:

  • decode_etpf_chunk_pages(meta, extra) (tools/tex_headers.py:355-357): Returns None when meta or extra is a bool instead of treating True/False as 1/0.
  • compact_surface_layout(width, height, mips, element_bytes, block, tile) (tools/tex_headers.py:401-415): Rejects bool and non-int values for width, height, mips, element_bytes, block, and tile with ValueError (instead of accepting True as 1 or raising AttributeError on float.bit_length()).

Scope & Conflict Check

Verification

AI-assisted. Tested on Windows 11, Python 3.12.10 (GPU: AMD Radeon RX 9070, driver 32.0.32029.2010; CPU-only tests, synthetic inputs only, zero game data):

Command Result
python -I tests/test_tex_headers_validation.py 2/2 passed
python -I tests/test_tex_headers.py 77/77 passed
python -I tests/test_tex_headers_report_paths.py 8 tests (7 passed, 1 skipped)
python -m compileall -q make_game.py tools tests exit 0
python -I scripts/check_no_game_data.py tools/tex_headers.py tests/test_tex_headers_validation.py exit 0

@sds-228 sds-228 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Focused suite passes 2/2 at this head; both new validation tests fail against the pre-change source. Boolean and non-integer inputs are rejected without changing valid decoding.

AI-assisted (OpenCode).

@garuspl

garuspl commented Nov 23, 2026

Copy link
Copy Markdown

Tested 3db4f37 on Windows 11 (CPU only, no GPU needed): pass

Windows 11 Pro, Python 3.14.7, no GPU or game files involved; pytest/numpy/Pillow pinned from tests/requirements.txt in a fresh venv. Method: PR head merged onto main 867d922, the PR's test files run with python -m pytest before and after the merge, plus python -m compileall -q on the changed files (clean).

  • tests/test_tex_headers_validation.py (new): 2 passed, 13 subtests passed.

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

@RAINighty

Copy link
Copy Markdown

Tested 3db4f3740 merged with main 867d922f0 (clean merge) on Windows 11 (10.0.26300), Python 3.13.15 in UTF-8 mode (PYTHONUTF8=1; venv with the pinned tests/requirements.txt), with llvm-mc 21.1.8 (AMDGPU) and SPIRV-Tools v2026.4 on PATH: pass.

  • tests/test_tex_headers_validation.py with this PR: passes (Ran 2 tests in 0.001s, OK). On main: a new file, so there is nothing to run there.
  • Negative control: this PR's test with main's version of tools/tex_headers.py fails (Ran 2 tests in 0.005s, FAILED (failures=8, errors=2)), so the new test does catch the problem.
  • Code not reviewed beyond running it. No GPU or game files.

AI-assisted (Claude Code).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants