fix(tools): decode timeline JSON with utf-8-sig in pad_timeline #9258
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/9258"
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 emirplus on 2026-10-21T16:44:48Z.
What
When controller timeline JSON files contain a UTF-8 byte-order mark (BOM) (e.g. created or saved by text editors on Windows), reading them with
read_text(encoding="utf-8")results injson.decoder.JSONDecodeError: Unexpected UTF-8 BOM (decode using utf-8-sig).encoding="utf-8-sig"inpad_timeline.pyso leading BOMs are cleanly stripped prior to JSON parsing.argvargument inmain(argv=None)with standard UTF-8 stream reconfiguration for programmatic and cross-platform CLI invocation.Tested
python tools/check_conventions.py --base origin/mainpython -m unittest tools/tests/test_pad_timeline.pyChecklist
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 xXPBSXx on 2026-10-21T17:53:13Z.
Linux data point for
ef1c8d5ca2(WSL2, Ubuntu 24.04, kernel 6.18 - a virtualised kernel, not bare-metal Linux; Python 3.12.3), this head merged ontomain950388bfd(clean merge),python3 -I tools/tests/test_pad_timeline.py:test_pad_timeline.pyon top ofmainwithout the PR's source change): FAILED (1 failure).Not tested: macOS, Windows.
AI-assisted (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by THEMANnt on 2026-10-24T23:47:10Z.
Review: CHANGES_REQUESTED
Reviewed c512089cc840 against 938812df1403. Changes requested for a Unicode output regression introduced by the stream reconfiguration.
tools/pad_timeline.py:81–83— Keep safe error handling when configuring UTF-8stream.reconfigure(encoding="utf-8")resets the error handler to strict, replacing a configured safe policy. I reproduced this on Windows with an actual command-file name containing U+DCFF andPYTHONIOENCODING=utf-8:backslashreplace. The baseline queues the command and exits 0. The exact PR head also writes the command, then raises UnicodeEncodeError at the success-message print and exits 1 because the path contains the surrogate. This reports failure after the command was already queued and can prompt an unnecessary retry. The reproduction uses real CLI subprocesses and temporary files; no production source is amended.Please preserve an appropriate safe error policy when changing the encoding, for example explicit backslashreplace, and add a subprocess regression that checks the successful status after writing a command to such a filename. Keep BOM acceptance coverage.
Validation: Windows x64 / CPython 3.11: timeline suite 18 passed, 1 POSIX skip; 19 total. Neighboring pad-input suite 12 passed, 2 POSIX skips; 14 total. Baseline timeline suite: 17 passed, 1 skip. The new BOM test fails on old production with exit 2 and passes at the head; the independent surrogate-filename reproduction above exposes the new regression. Conventions, whitespace and registration pass. Hosted relinker matrix/ASan and conventions succeed; product jobs are skipped.
Scope: Python CLI/file behavior only; no real controller or title was run. Local POSIX permission cases remain skipped.
Imported from boykopovar/AnyPS5. Originally posted by malekaifa on 2026-10-30T14:01:05Z.
Review: COMMENTED
Freshness note for the eventual rebase/integration of this PR: current
mainnow has a second consumer of the same timeline JSON contract,tools/preview_pad_timeline.py, introduced later in1f563f246e(2026-10-27), so it is not present in this PR's two-file diff.I independently checked current main
b1b5353cfcee098ed17e3ba8a6e616bee97c9215on Windows/Python 3.12. A valid version-1 timeline encoded with a leading UTF-8 BOM gives:The preview tool currently reads the file with
encoding="utf-8", while this PR intentionally changespad_timeline.pyto accept the same input withutf-8-sig. So after this PR is refreshed, the two timeline entry points would otherwise disagree about whether the same valid JSON file is accepted.Please preserve the BOM change here, but when rebasing onto current main also update the preview reader (or coordinate an explicit follow-up) and add a focused preview regression. This is a post-PR main-drift integration gap, not a defect in the original
c512089cc840...patch as authored.AI-assisted: yes. I ran the current-main preview reproduction above; I did not rerun the PR's full test matrix.
Imported from boykopovar/AnyPS5. Originally posted by THEMANnt on 2026-11-02T06:00:44Z.
Review: APPROVED
Re-reviewed
e62a0f26040d95b8fb35200348ef4e8bfc5c01e0. My previous Unicode-output change request onc512089cc840is addressed.Explicit
errors="backslashreplace"keeps the success message printable when the command-file path contains a lone surrogate. The CLI subprocess regression verifies exit 0, the written command, and the escaped filename; UTF-8 BOM acceptance coverage remains and passes.Validation: Windows x64 / Python 3.11.9: timeline suite 22 passed, 2 skipped; neighboring pad-input suite 19 passed, 2 skipped. The surrogate regression ran without skipping. As a negative control, the same new regression against the previous head's production code fails with the original
UnicodeEncodeErrorat the success-message print. Diff whitespace check passes.No remaining blocker found in this two-file patch. Scope: Python CLI/file behavior; no controller or title was run. POSIX permission and unavailable symlink cases remain untested locally.