tooling: validate section_probe --first and --last as section tags #641
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/647"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from R0Y00/Xbox2Windows. Originally posted by louisdibiasi on 2026-11-22T17:28:44Z.
Change
tools/section_probe.pymatches sections whose four-character tags satisfy[A-Z0-9_]{4}, but--firstand--lastaccepted any string. A lowercase or wrong-length tag can never match, so the run exits 0 with"section_records": 0, which looks the same as an archive that has no such section. A tag outside ASCII raisedUnicodeEncodeError. This validates both options with the same pattern through an argparsetype, so a bad tag exits with status 2 and a usage message.Independent problem, no linked issue.
Verification
Commit under test:
b1faec8onbcdce96, Windows 11, Python 3.12.10.Synthetic archive: a zlib stream holding
HEADandFOOTsections.python -B tools/section_probe.py s.bin --first <F> --last FOOT:--firsthead"section_records": 0argument --first: 'head' is not a section tag: use four characters from A-Z, 0-9 and _HEA"section_records": 0HÉADUnicodeEncodeError, exit 1HEADNew
test_section_probe_cli_validates_tagsintests/resource_ranges_check.pyruns lowercase, short, long and non-ASCII values for both options, requires exit 2 and no traceback, then checks a valid pair still reports 1 section.AssertionError: 0 != 2.python -B tests/resource_ranges_check.py->Ran 20 tests ... OK.The documented usage (
--first PSIN --last CHKSin docs/experiments.md) uses valid tags.Evidence and follow-up
Synthetic data only. A missing archive path still raises
FileNotFoundError; not changed here.Checklist
AI-assisted: I used Claude to find the bug and draft the change. I ran the reproductions and tests above myself.
Imported from R0Y00/Xbox2Windows. Originally posted by legacy-code-archaeologist on 2026-11-22T18:27:14Z.
The description names
b1faec8as the commit under test. The current head is39ee24a("Use ASCII-safe diagnostics for invalid section tags", on2bb9ee0). I re-ran the check at the head on Windows 11 26100.9168 with Python 3.12.10:python -B tests/resource_ranges_check.pyreportsOK. The head merges cleanly withmainat719552e.AI-assisted (Claude Code).