4 Commits

Author SHA1 Message Date
15a6cdb492 isa_coverage: an XML file with no instructions is one error line, not a ZeroDivisionError
A well-formed XML that is not the spec (<a/>, <isa><ISA/></isa>) parsed clean, came back with
zero instructions, and markdown() divided the class shares by that zero. Check for an empty
instruction set in main and report through ap.error, the tool's pattern for bad input (exit 2,
one line, the path and a reason). Probed 13 malformed structures: only the zero-instruction
divide escaped, no AttributeError or KeyError. Adds the case to tests/test_bad_input_errors.py;
it fails without the change (3 failures, a traceback each) and passes with it.

AI-assisted: written by Qwen (model qwen3.8-gx10-claude-compatible).
Co-Authored-By: Qwen qwen3.8-gx10-claude-compatible <noreply@qwen.ai>
2026-11-22 14:12:24 -03:00
0273fb4acc isa_coverage: an unreadable or malformed --isa or --translator file is one error line, not a traceback
A missing, directory or unparsable --isa died in ET.parse, and a missing, directory or
non-UTF-8 --translator died in the open() of scan_translator: tracebacks for inputs a
user can mistype. Catch OSError, UnicodeDecodeError and ET.ParseError around the calls
in main and report through ap.error, the tool's existing pattern (exit 2, one line, the
path and a reason), leaving the functions and the classification untouched. Adds five
cases to tests/test_bad_input_errors.py; they fail without the change and pass with it.

AI-assisted: written by Qwen (model qwen3.8-gx10-claude-compatible).
Co-Authored-By: Qwen qwen3.8-gx10-claude-compatible <noreply@qwen.ai>
2026-11-22 14:06:53 -03:00
7b3817a9fb rpf9_carve.py: reject a file that is not an RPF9 archive (BUILD-98)
The header magic was never checked, so a non-RPF9 file "carved" to 0
streams with exit 0 and looked like an empty archive.

- rpf9_carve.py: the file must start with 9FPR (the tag RPF9 stored
  little-endian, docs/rpf.md and docs/bvh.md); otherwise one error line
  naming the file and a non-zero exit, before the out dir is created.
- Tests: synthetic non-RPF9 file for rpf9_carve.py and, through it, for
  gamedata_index.py (which already reports a carver rejection as one ERROR
  line since main's own change). The existing fixtures wrote the tag as
  RPF9, which is not what real archives contain; they now write 9FPR.

--limit 0 and negative values were already rejected on main (byte_count).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-21 20:59:04 -05:00
6516dfea46 fix(tools): report clear errors for empty, short and out-of-range input
BUILD-30: anim_index, rbf0_index and restofworld_index now reject an
empty archive with a named error instead of mmap's traceback.
rpf9_carve rejects an empty or shorter-than-header archive and a
--start at or past the file size before it divides by the span.
audio_config exits with a named error when the input has no records
instead of formatting None as a hex id.

The new synthetic test covers every case; the existing tests for the
five tools still pass.
2026-11-21 23:31:48 +01:00