tooling: report unreadable torrents in verify_build as usage errors #640

Merged
louisdibiasi merged 2 commits from upstream-pr/646 into main 2026-11-22 18:46:49 +00:00
louisdibiasi commented 2026-11-22 17:28:42 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by louisdibiasi on 2026-11-22T17:28:42Z.


Change

tools/verify_build.py decodes the torrent and reads its file list without handling a torrent that is valid bencode but not a multi-file torrent. Each of these ended in a traceback with exit status 1:

  • single-file torrent: KeyError: b'files'
  • info is not a dictionary: TypeError
  • a path that is not UTF-8: UnicodeDecodeError
  • negative size / invalid list: ValueError: Invalid torrent file list or piece length
  • a directory argument that does not exist: FileNotFoundError

Exit status 1 also means "payload failed verification" (return 0 if report["torrent_payload_passed"] else 1), so a crash can be read as a verification result. This reports the same problems through parser.error (exit 2, no traceback, no report written), the way manifest selection already does.

Independent problem, no linked issue.

Verification

Commit under test: c8b6dc7 on bcdce96, Windows 11, Python 3.12.10.

Base vs this branch, python -B tools/verify_build.py <package> --output r.json on synthetic packages (an empty layout.xml and a payload.torrent):

Input Base This branch
single-file torrent KeyError: b'files', exit 1 payload.torrent is not a readable multi-file torrent: KeyError: b'files', exit 2
d4:infoi7ee TypeError: 'int' object is not subscriptable, exit 1 same message form, exit 2
path byte \xff UnicodeDecodeError, exit 1 exit 2
negative length ValueError: Invalid torrent file list or piece length, exit 1 exit 2
missing directory FileNotFoundError, exit 1 cannot read <dir>: The system cannot find the file specified, exit 2

New check_unreadable_torrent_is_a_usage_error in tests/layout_chunks_check.py covers the four torrent shapes and the missing directory (exit 2, "payload.torrent" named, no Traceback, no report file).

  • Base: python -B tests/layout_chunks_check.py -> AssertionError on the first case (returncode 1, KeyError: b'files').
  • This branch: layout chunk summary ok.
  • python -B tests/intake/check.py <build>/intake_candidate.exe <build>/intake_provider.dll (the static_exe_intake test, run directly against my dev build) passes.

Evidence and follow-up

Synthetic bytes only. The invalid-file-list case changes from a traceback with exit 1 to a usage error with exit 2. Found while testing: a layout.xml that is not valid XML still ends in an uncaught ParseError traceback; I left that out to keep this PR to the torrent, and can send it separately.

Checklist

  • One reviewable behavior.
  • Exact commands and results above.
  • Negative control: the new check fails on base.
  • No README/docs change needed.
  • No game files, dumps, links or secrets.

AI-assisted: I used Claude to find the bug and draft the change. I ran the reproductions and tests above myself.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6545455417 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/646). Originally posted by [louisdibiasi](https://github.com/louisdibiasi) on 2026-11-22T17:28:42Z. --- ## Change `tools/verify_build.py` decodes the torrent and reads its file list without handling a torrent that is valid bencode but not a multi-file torrent. Each of these ended in a traceback with exit status 1: - single-file torrent: `KeyError: b'files'` - `info` is not a dictionary: `TypeError` - a path that is not UTF-8: `UnicodeDecodeError` - negative size / invalid list: `ValueError: Invalid torrent file list or piece length` - a directory argument that does not exist: `FileNotFoundError` Exit status 1 also means "payload failed verification" (`return 0 if report["torrent_payload_passed"] else 1`), so a crash can be read as a verification result. This reports the same problems through `parser.error` (exit 2, no traceback, no report written), the way manifest selection already does. Independent problem, no linked issue. ## Verification Commit under test: c8b6dc7 on bcdce96, Windows 11, Python 3.12.10. Base vs this branch, `python -B tools/verify_build.py <package> --output r.json` on synthetic packages (an empty `layout.xml` and a `payload.torrent`): | Input | Base | This branch | |---|---|---| | single-file torrent | `KeyError: b'files'`, exit 1 | `payload.torrent is not a readable multi-file torrent: KeyError: b'files'`, exit 2 | | `d4:infoi7ee` | `TypeError: 'int' object is not subscriptable`, exit 1 | same message form, exit 2 | | path byte `\xff` | `UnicodeDecodeError`, exit 1 | exit 2 | | negative length | `ValueError: Invalid torrent file list or piece length`, exit 1 | exit 2 | | missing directory | `FileNotFoundError`, exit 1 | `cannot read <dir>: The system cannot find the file specified`, exit 2 | New `check_unreadable_torrent_is_a_usage_error` in `tests/layout_chunks_check.py` covers the four torrent shapes and the missing directory (exit 2, "payload.torrent" named, no `Traceback`, no report file). - Base: `python -B tests/layout_chunks_check.py` -> AssertionError on the first case (`returncode 1`, `KeyError: b'files'`). - This branch: `layout chunk summary ok`. - `python -B tests/intake/check.py <build>/intake_candidate.exe <build>/intake_provider.dll` (the `static_exe_intake` test, run directly against my dev build) passes. ## Evidence and follow-up Synthetic bytes only. The invalid-file-list case changes from a traceback with exit 1 to a usage error with exit 2. Found while testing: a `layout.xml` that is not valid XML still ends in an uncaught `ParseError` traceback; I left that out to keep this PR to the torrent, and can send it separately. ## Checklist - [x] One reviewable behavior. - [x] Exact commands and results above. - [x] Negative control: the new check fails on base. - [x] No README/docs change needed. - [x] No game files, dumps, links or secrets. AI-assisted: I used Claude to find the bug and draft the change. I ran the reproductions and tests above myself.
upstream-sync closed this pull request 2026-11-24 06:44:08 +00:00
legacy-code-archaeologist commented 2026-11-24 06:48:38 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by legacy-code-archaeologist on 2026-11-22T18:27:11Z.


Verified on Windows 11 26100.9168 with Python 3.12.10. python -B tests/layout_chunks_check.py prints layout chunk summary ok at head c8b6dc7, which merges cleanly with main at 719552e.

This PR edits the same two files as #643 (tools/verify_build.py, tests/layout_chunks_check.py), and #644 also edits that test. Merging #643, #644 and #646 onto main in that order gives no conflicts, and the combined test still prints layout chunk summary ok.

AI-assisted (Claude Code).

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7083613065 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/646#issuecomment-7083613065). Originally posted by [legacy-code-archaeologist](https://github.com/legacy-code-archaeologist) on 2026-11-22T18:27:11Z. --- Verified on Windows 11 26100.9168 with Python 3.12.10. `python -B tests/layout_chunks_check.py` prints `layout chunk summary ok` at head `c8b6dc7`, which merges cleanly with `main` at `719552e`. This PR edits the same two files as #643 (`tools/verify_build.py`, `tests/layout_chunks_check.py`), and #644 also edits that test. Merging #643, #644 and #646 onto `main` in that order gives no conflicts, and the combined test still prints `layout chunk summary ok`. AI-assisted (Claude Code).
Sign in to join this conversation.
No reviewers
No labels
No milestone
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.

Reference
R0Y00/Xbox2Windows!640
No description provided.