fix(tools): report controller command file errors cleanly #11360

Closed
arcwiser wants to merge 1 commit from upstream-pr/11360 into main
arcwiser commented 2026-10-26 08:23:33 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by arcwiser on 2026-10-26T08:23:33Z.


What

Catch file I/O errors throughout controller command sequencing, temporary-file creation and atomic replacement in pad_input.py, reporting an argparse error instead of an uncaught traceback. Preserve the existing command and temporary-file cleanup on failure.

Draft because #6531 and its rebased follow-up #11312 overlap the missing-parent-directory symptom and modifies the same CLI function. This change additionally handles read, temporary-file and replacement failures; coordination is needed before marking it ready. #10206 and #10578 modify other behavior in the same tool.

Tested

Windows, Python 3.12, upstream base 204c6747d0a1cbaf932def3dea0778810cc3935e; published head 12a121f13ad4f80367e01a30e69a1aa65051486b.

  • Regression tests failed on unchanged code for the missing-directory case and three injected permission failures.
  • python -m unittest discover -s tools/tests -p 'test_pad_*.py': 31 passed, 3 POSIX-only skips.
  • python tools/check_conventions.py --base origin/main: passed.
  • git diff --check origin/main HEAD: passed.
  • python tools/pr_overlap.py --branch fix/pad-input-io-errors --repo boykopovar/AnyPS5: completed successfully. Conflicting hunks: #10206 in tools/tests/test_pad_input.py; #11312 in tools/pad_input.py and tools/tests/test_pad_input.py. #6531 conflicts with main, preventing automatic comparison; its shared files were inspected manually.

No game, GPU, POSIX runtime or C++ build tested. Base freshness and overlap coordination remain to be resolved before ready-for-review.

Checklist

  • Based on current main; no other open PR implements the same functions (base recorded above; partial overlap #6531/#11312 and shared-file conflict #10206 require coordination)
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes

Overlap details

#11312 rebases #6531's path validation and output encoding changes and adds a read-permission regression expecting the raw exception. This branch instead reports read, temporary-file and replacement errors through argparse and tests all three failure stages. Combining the branches requires retaining its path/encoding changes, this broader error handling, and reconciling the differing unreadable-file test expectation. #10206 adds stream/entry-point changes and tests at the same insertion point. This draft is not ready to merge until the ordering and shared tests are coordinated. No dependencies declared yet.

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5014300035 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11360). Originally posted by [arcwiser](https://github.com/arcwiser) on 2026-10-26T08:23:33Z. --- ### What Catch file I/O errors throughout controller command sequencing, temporary-file creation and atomic replacement in `pad_input.py`, reporting an argparse error instead of an uncaught traceback. Preserve the existing command and temporary-file cleanup on failure. Draft because #6531 and its rebased follow-up #11312 overlap the missing-parent-directory symptom and modifies the same CLI function. This change additionally handles read, temporary-file and replacement failures; coordination is needed before marking it ready. #10206 and #10578 modify other behavior in the same tool. ### Tested Windows, Python 3.12, upstream base `204c6747d0a1cbaf932def3dea0778810cc3935e`; published head `12a121f13ad4f80367e01a30e69a1aa65051486b`. - Regression tests failed on unchanged code for the missing-directory case and three injected permission failures. - `python -m unittest discover -s tools/tests -p 'test_pad_*.py'`: 31 passed, 3 POSIX-only skips. - `python tools/check_conventions.py --base origin/main`: passed. - `git diff --check origin/main HEAD`: passed. - `python tools/pr_overlap.py --branch fix/pad-input-io-errors --repo boykopovar/AnyPS5`: completed successfully. Conflicting hunks: #10206 in `tools/tests/test_pad_input.py`; #11312 in `tools/pad_input.py` and `tools/tests/test_pad_input.py`. #6531 conflicts with main, preventing automatic comparison; its shared files were inspected manually. No game, GPU, POSIX runtime or C++ build tested. Base freshness and overlap coordination remain to be resolved before ready-for-review. <!-- OS, title or homebrew, what was checked. "Not tested" is a valid answer. A performance change: the summary lines of main and of this PR from the same machine and scene, with the traces attached, captured as the Performance report issue form describes. --> ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [ ] Based on current `main`; no other open PR implements the same functions (base recorded above; partial overlap #6531/#11312 and shared-file conflict #10206 require coordination) - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: <!-- #PR, or none --> none - [x] Fixes: <!-- issue it closes as Fixes #N, or none --> none - [x] Unblocks: <!-- title ID and Game bring-up discussion, e.g. PPSA01325 #3232, or none --> none - [x] GPUs tested: <!-- for AGC, shader recompiler or VideoOut changes: vendor, model, driver and OS of each GPU the GPU tests ran on; otherwise n/a --> n/a - [x] AI-assisted: <!-- yes / no --> yes ### Overlap details #11312 rebases #6531's path validation and output encoding changes and adds a read-permission regression expecting the raw exception. This branch instead reports read, temporary-file and replacement errors through argparse and tests all three failure stages. Combining the branches requires retaining its path/encoding changes, this broader error handling, and reconciling the differing unreadable-file test expectation. #10206 adds stream/entry-point changes and tests at the same insertion point. This draft is not ready to merge until the ordering and shared tests are coordinated. No dependencies declared yet.
MarcZX10 commented 2026-11-17 08:59:05 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-17T08:59:05Z.

Review: COMMENTED


Reviewed — no blocking findings

Nothing blocks this; the points below are optional, and no approval is given while the PR is a draft.

What I ran

  • Head 12a121f13ad4f80367e01a30e69a1aa65051486b, base main. Merged-preview check: not run.
  • Read the description, commits, manifest, files list and diff from the prepared review folder.
  • Read tools/pad_input.py at head (lines 1-112) and tools/tests/test_pad_input.py at head (lines 1-40), plus the changed test hunk from the diff.
  • No tests, build or repository precheck were run: there is no checkout here to run them in, and the reader only reads files.
Commands
python3 repo_read.py cat tools/pad_input.py 1 130
python3 repo_read.py cat tools/tests/test_pad_input.py 1 40
python3 repo_read.py search "def queue|def setUp|def next_sequence" tools

The search call returned no matches, so I did not rely on it.

Results

Check Result Note
Diff read passed 2 files, 2 hunks
pad_input.py at head passed read in full
Test file at head passed changed hunk and lines 1-40 only
Test suite not run no runner here
Repository precheck not run not run here

Findings

Blocking

None.

Non-blocking

None verified.

Not verified

  • The test results in the description (31 passed, 3 POSIX skips, regression tests failing on unchanged code, Windows with Python 3.12). I did not run them.
  • tools/tests/test_pad_input.py:142 asserts "No such file or directory" in stderr. That is the POSIX wording of the OS error. The description says the suite passed on Windows, where the wording may differ. I could not check this.
  • tools/tests/test_pad_input.py lines 41-162 at head were not read. Only the changed hunk (lines 136-159) was checked.
  • Hosted CI for this head: the review folder has no check status, so it was not checked.
  • Overlap with #6531, #11312 and #10206: not inspected. The description says it is still open.
  • The checklist item "Based on current main" is unchecked in the description.

To get this to a good state

Nothing is required.

Optional:

  • Settle the overlap with #6531, #11312 and #10206 before marking the PR ready, as the description says.
  • Confirm that the missing-directory test passes on Windows, or make its assertion independent of the OS message.
  • Rerun the tests listed in the description on the new head and attach the output.

Sources

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5935541893 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11360#pullrequestreview-5935541893). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-17T08:59:05Z. **Review:** COMMENTED --- # Reviewed — no blocking findings Nothing blocks this; the points below are optional, and no approval is given while the PR is a draft. ## What I ran - Head `12a121f13ad4f80367e01a30e69a1aa65051486b`, base `main`. Merged-preview check: not run. - Read the description, commits, manifest, files list and diff from the prepared review folder. - Read `tools/pad_input.py` at head (lines 1-112) and `tools/tests/test_pad_input.py` at head (lines 1-40), plus the changed test hunk from the diff. - No tests, build or repository precheck were run: there is no checkout here to run them in, and the reader only reads files. <details> <summary>Commands</summary> ```sh python3 repo_read.py cat tools/pad_input.py 1 130 python3 repo_read.py cat tools/tests/test_pad_input.py 1 40 python3 repo_read.py search "def queue|def setUp|def next_sequence" tools ``` The `search` call returned no matches, so I did not rely on it. </details> ## Results | Check | Result | Note | |---|---|---| | Diff read | passed | 2 files, 2 hunks | | `pad_input.py` at head | passed | read in full | | Test file at head | passed | changed hunk and lines 1-40 only | | Test suite | not run | no runner here | | Repository precheck | not run | not run here | ## Findings ### Blocking None. ### Non-blocking None verified. ## Not verified - The test results in the description (31 passed, 3 POSIX skips, regression tests failing on unchanged code, Windows with Python 3.12). I did not run them. - `tools/tests/test_pad_input.py:142` asserts `"No such file or directory"` in stderr. That is the POSIX wording of the OS error. The description says the suite passed on Windows, where the wording may differ. I could not check this. - `tools/tests/test_pad_input.py` lines 41-162 at head were not read. Only the changed hunk (lines 136-159) was checked. - Hosted CI for this head: the review folder has no check status, so it was not checked. - Overlap with #6531, #11312 and #10206: not inspected. The description says it is still open. - The checklist item "Based on current `main`" is unchecked in the description. ## To get this to a good state Nothing is required. Optional: - Settle the overlap with #6531, #11312 and #10206 before marking the PR ready, as the description says. - Confirm that the missing-directory test passes on Windows, or make its assertion independent of the OS message. - Rerun the tests listed in the description on the new head and attach the output. ## Sources - [`tools/pad_input.py` lines 20-25](https://github.com/boykopovar/AnyPS5/blob/12a121f13ad4f80367e01a30e69a1aa65051486b/tools/pad_input.py#L20-L25): `previous_sequence` catches only `FileNotFoundError`, so other read errors reach the new handler at line 106. - [`tools/pad_input.py` lines 85-107](https://github.com/boykopovar/AnyPS5/blob/12a121f13ad4f80367e01a30e69a1aa65051486b/tools/pad_input.py#L85-L107): the outer `try` and `except (OSError, ValueError)`, with the cleanup in the `finally` kept.
ligmaSec commented 2026-12-03 17:01:03 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T17:01:03Z.

Review: COMMENTED


The exact controller-command Python suite passed 15 cases on Linux with one skip. It covers the missing parent directory and failed open or replace while preserving the previous command. Current main conflicts in both the tool and the test suite. Keep the newer touch fields and existing replace_command retry path when applying this error handling.

AI-assisted: yes.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6174488141 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11360#pullrequestreview-6174488141). Originally posted by [ligmaSec](https://github.com/ligmaSec) on 2026-12-03T17:01:03Z. **Review:** COMMENTED --- The exact controller-command Python suite passed 15 cases on Linux with one skip. It covers the missing parent directory and failed open or replace while preserving the previous command. Current main conflicts in both the tool and the test suite. Keep the newer touch fields and existing `replace_command` retry path when applying this error handling. AI-assisted: yes.

Pull request closed

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
boykopovar/AnyPS5!11360
No description provided.