fix(tools): normalize pad input output encoding and validate target path #6531
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/6531"
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 boykopovar/AnyPS5. Originally posted by Laronza on 2026-10-15T19:03:06Z.
What
tools/pad_input.pywrites controller commands using explicitencoding="utf-8"andnewline="\n"on temporary file creation, guaranteeing uniform LF line endings and UTF-8 encoding across Windows and POSIX hosts.Tested
python -m unittest tools.tests.test_pad_input(13 passed, 0 failed).python -m unittest discover tools/tests(498 passed, 0 failed).ctest --test-dir build-relinker -R pad_input --output-on-failure(1/1 passed).python tools/check_conventions.py --base origin/main(passed with 0 findings).Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-19T03:49:18Z.
Review: CHANGES_REQUESTED
Thanks, the directory / missing-parent errors and the explicit
newline="\n"look right. One thing to change:tools/pad_input.py:24: the newexcept (FileNotFoundError, IsADirectoryError, PermissionError)is out of scope and not tested.IsADirectoryErrorcan't happen any more (main()rejects directories first).PermissionErrornow silently resets the sequence for an unreadable command file and then overwrites it, where before it failed loudly. Please revert this line toexcept FileNotFoundError:, or keepPermissionErroronly with a test and a note in the PR body on why it is wanted.Minor:
test_output_has_consistent_lf_newlines_and_utf8also passes onmainon Linux (text mode already writes\nthere), so it only guards Windows.Imported from boykopovar/AnyPS5. Originally posted by THEMANnt on 2026-10-24T12:27:37Z.
Review: CHANGES_REQUESTED
Reviewed head
be8b84b43caba2a3257ed99ec9445e2aab08d0fbagainst pinned base44df21632125dbe3113a19173e7ebb879da53003, including the local candidate amendments.main()now rejects directory targets and missing parents through CLI errors and writes explicit UTF-8/LF output.newline="\n"correctly preserves LF. The candidate also restores propagation of unreadable-file errors fromprevious_sequence(), addressing the pristine PR's sequence-reset risk. Existing clock-reset, malformed-command, stick-schema, and exhaustion assertions remain intact.Changes are required in the candidate's added POSIX test at
tools/tests/test_pad_input.py:133. After expectingPermissionError, it reads the file while its mode remains000; restoring permissions through cleanup happens too late. An unprivileged run therefore errors despite correct production behavior, while a privileged writer can bypass the expected denial. Restore readability before verifying contents and account for privileged execution.The controller executed
tools/tests/test_pad_input.pyon Windows AMD64 with Python 3.11.9: baseline reported 10 tests with 2 skipped, pristine PR 13 with 2 skipped, and candidate 14 with 3 skipped. Candidate tests against baseline code produced the required old-code LF assertion failure plus two path-validation errors. The unreadable-file test was skipped, so this control provides no execution evidence for that case. Local whitespace and conventions checks succeeded.GitHub-reported effective
eligibility,conventions, andintakechecks succeeded;relinker,windows,linux,register-context, andwrite-watchwere skipped. The earlier cancelled conventions run was superseded by the successful same-workflow execution. These results do not establish passing product builds. Broader discovery and CTest results remain author-reported; no game or GPU validation is established.Imported from boykopovar/AnyPS5. Originally posted by THEMANnt on 2026-10-25T23:09:31Z.
Review: CHANGES_REQUESTED
Re-reviewed
be8b84b43caba2a3257ed99ec9445e2aab08d0fb. Changes requested for a reproduced regression in the submitted production code.Correction to my earlier review: the POSIX test criticized there existed only in the reviewer's local candidate, not in this PR. That test is not a valid author-facing finding, and I retract that part of the feedback. The candidate's production fix also was not part of the submitted PR.
tools/pad_input.py:23— Preserve read errors instead of resetting an existing command's sequenceThe submitted change catches PermissionError in previous_sequence and returns zero. If an existing command cannot be read but its directory permits replacement, main can then overwrite it using the current clock value rather than advancing the existing sequence. After a clock reset this goes backwards, so a consumer that already observed the old sequence can ignore the newly queued pulse. Abort and preserve the command when reading fails; only an absent command should take the missing-file path.
Validation: A controlled read-denial reproduction executes the exact current main with an existing
1000 16384 300command and clock value 100. Current head silently replaces it with100 16384 300; the original baseline propagates PermissionError and retains the original bytes. This uses a mocked read denial on Windows, not a real POSIX chmod test. The exact submitted suite also passes 11 tests with 2 POSIX skips (13 total), demonstrating that its present coverage misses this case.Scope: The reproduction tests the actual submitted code, with no production edits or candidate tests attributed to the author. Add coverage that rejects unreadable existing commands and verifies they remain unchanged. No game/runtime execution was performed.
Pull request closed