[PR #1599] bvh_groups: validate scan bounds and --json upfront, use same_report_path, catch write OSError (BVH-GROUPS-GUARDS-AND-IO) #1618

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/1599
Author: @IlyassRS3
Created: 11/25/2026
Status: 🔄 Open

Base: main ← Head: fix/bvh-groups-guards-and-io


📝 Commits (1)

  • 042a2d2 bvh_groups: validate scan bounds and --json upfront, use same_report_path, catch write OSError

📊 Changes

2 files changed (+91 additions, -7 deletions)

View changed files

📝 tests/test_bvh_groups.py (+55 -0)
📝 tools/bvh_groups.py (+36 -7)

📄 Description

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

Summary

  • Validate start, limit, and max_inflate in scan() before the empty-archive fast path so out-of-range start on empty files, limit <= 0, max_inflate <= 0, and bool values raise ValueError (previously limit=0 scanned the whole archive and max_inflate=0/True crashed with struct.error in bvh_index.classify).
  • Validate archive and --json before scanning (reject empty/whitespace strings, directories, trailing separators, and missing parent directories) and use the shared report_paths.same_report_path() guard instead of raw os.path.samefile().
  • Catch OSError from write_json_report() in main() and publish --json before printing stdout (exiting with code 2 and one stderr line instead of a traceback), and enforce allow_nan=False in write_json_report().

Verification

  • python3 -W error -I tests/test_bvh_groups.py -v: 16/16 passed.
  • python3 -I tests/test_text_write_line_endings.py: 3/3 passed.
  • python3 -I scripts/check_no_game_data.py tools/bvh_groups.py tests/test_bvh_groups.py: passed.
  • python3 -m compileall -q tools/bvh_groups.py tests/test_bvh_groups.py: passed.
  • Mutation check (running tests/test_bvh_groups.py against unpatched main:tools/bvh_groups.py): failures=11, errors=3 across all new regression tests.

AI-assisted: yes
GPUs tested: none (CPU-only Python BVH descriptor tool; synthetic streams 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/1599 **Author:** [@IlyassRS3](https://github.com/IlyassRS3) **Created:** 11/25/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/bvh-groups-guards-and-io` --- ### 📝 Commits (1) - [`042a2d2`](https://github.com/ubiquitarianism/leonida/commit/042a2d206af6b681d234e3ba7916056ccb7d084d) bvh_groups: validate scan bounds and --json upfront, use same_report_path, catch write OSError ### 📊 Changes **2 files changed** (+91 additions, -7 deletions) <details> <summary>View changed files</summary> 📝 `tests/test_bvh_groups.py` (+55 -0) 📝 `tools/bvh_groups.py` (+36 -7) </details> ### 📄 Description Item: `BVH-GROUPS-GUARDS-AND-IO` (unclaimed — coordination issue #14 is at GitHub's 2,500-comment cap with no successor open issue yet, and 0 open PRs touch `tools/bvh_groups.py`). ### Summary - Validate `start`, `limit`, and `max_inflate` in `scan()` before the empty-archive fast path so out-of-range `start` on empty files, `limit <= 0`, `max_inflate <= 0`, and `bool` values raise `ValueError` (previously `limit=0` scanned the whole archive and `max_inflate=0`/`True` crashed with `struct.error` in `bvh_index.classify`). - Validate `archive` and `--json` before scanning (reject empty/whitespace strings, directories, trailing separators, and missing parent directories) and use the shared `report_paths.same_report_path()` guard instead of raw `os.path.samefile()`. - Catch `OSError` from `write_json_report()` in `main()` and publish `--json` before printing stdout (exiting with code 2 and one stderr line instead of a traceback), and enforce `allow_nan=False` in `write_json_report()`. ### Verification - `python3 -W error -I tests/test_bvh_groups.py -v`: 16/16 passed. - `python3 -I tests/test_text_write_line_endings.py`: 3/3 passed. - `python3 -I scripts/check_no_game_data.py tools/bvh_groups.py tests/test_bvh_groups.py`: passed. - `python3 -m compileall -q tools/bvh_groups.py tests/test_bvh_groups.py`: passed. - Mutation check (running `tests/test_bvh_groups.py` against unpatched `main:tools/bvh_groups.py`): `failures=11, errors=3` across all new regression tests. AI-assisted: yes GPUs tested: none (CPU-only Python BVH descriptor tool; synthetic streams 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#1618
No description provided.