fix: reject aliased release note input and outputs #6424

Merged
MrMha merged 2 commits from upstream-pr/6424 into main 2026-10-17 13:08:03 +00:00
MrMha commented 2026-10-15 14:55:51 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MrMha on 2026-10-15T14:55:51Z.


What

Passing the same file, a symlink, or a hard link as the release-note input and an output overwrites the input JSON. Aliasing the two outputs also overwrites the full attachment with the shortened body. Check all three file identities before writing anything. The regression covers all three pairs and all three alias types while preserving previous bytes.

Tested

macOS 27.0.1 arm64, Python 3.12.14; tooling fixtures only, no title.

The new regression failed on main ff23657 before the fix. This branch was tested independently from that base.

python3 -m unittest tools.tests.test_package_release
Ran 27 tests in 0.163s
OK (skipped=3)
python3 tools/check_conventions.py --base ff23657f3437427fc5421857a6f9545e41806f2c --head HEAD
All conventions checks passed.

The combined local validation checkout containing all ten independent tooling fixes also built with ANYPS5_RELINKER_ONLY=ON, BUILD_TESTING=ON and passed all 172 CTest tests. Full Windows/Linux runtime and GPU tests were not run.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw; silent stubs are listed in technical debt (not applicable to this tooling change)
  • No notes, investigation .md files or images added to the repository
  • New third-party code is a submodule built from source (none added)
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4875262483 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6424). Originally posted by [MrMha](https://github.com/MrMha) on 2026-10-15T14:55:51Z. --- ### What Passing the same file, a symlink, or a hard link as the release-note input and an output overwrites the input JSON. Aliasing the two outputs also overwrites the full attachment with the shortened body. Check all three file identities before writing anything. The regression covers all three pairs and all three alias types while preserving previous bytes. ### Tested macOS 27.0.1 arm64, Python 3.12.14; tooling fixtures only, no title. The new regression failed on main `ff23657` before the fix. This branch was tested independently from that base. ```text python3 -m unittest tools.tests.test_package_release Ran 27 tests in 0.163s OK (skipped=3) python3 tools/check_conventions.py --base ff23657f3437427fc5421857a6f9545e41806f2c --head HEAD All conventions checks passed. ``` The combined local validation checkout containing all ten independent tooling fixes also built with `ANYPS5_RELINKER_ONLY=ON`, `BUILD_TESTING=ON` and passed all 172 CTest tests. Full Windows/Linux runtime and GPU tests were not run. ### Checklist - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except technical debt - [x] Unimplemented paths throw; silent stubs are listed in technical debt (not applicable to this tooling change) - [x] No notes, investigation `.md` files or images added to the repository - [x] New third-party code is a submodule built from source (none added) - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
github-actions[bot] commented 2026-10-15 15:03:46 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-15T15:03:46Z.


Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.

Pull request Shared files not compared
PR 5797 tools/tests/test_package_release.py
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6195251355 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6424#issuecomment-6195251355). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-15T15:03:46Z. --- <!-- pr-overlap --> Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap. | Pull request | Shared files not compared | |---|---| | [PR 5797](https://www.github.com/boykopovar/AnyPS5/pull/5797) | `tools/tests/test_package_release.py` |
realshinmalphur commented 2026-10-15 15:53:08 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by realshinmalphur on 2026-10-15T15:53:08Z.


Independent Linux validation of head bca123a7b9597408ba7e6d0d1fc6b89872831a37, using CPython 3.14.7.

  • python3 tools/tests/test_package_release.py: 27 tests, 24 passed and 3 platform-specific skips.
  • Running the new alias regression against the unmodified tool from main at 0c4816f6119e5dc1208b16b25a171d1c88aa18f4 produces 9 failed subcases, no errors or skips.
  • Separate real CLI checks confirm that shared outputs preserve an existing full changelog, normalized aliases to a nonexistent output create no file, and a dangling output symlink is preserved without creating its target. With distinct outputs, oversized full notes are retained and the shortened body is correct.
  • Locally merged this head with that main in an isolated checkout. All 27 tests still pass with the same 3 skips; conventions and whitespace checks pass.

This validates release-note tooling only; no native runtime or GPU tests were run. AI-assisted: yes (Codex).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6196296981 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6424#issuecomment-6196296981). Originally posted by [realshinmalphur](https://github.com/realshinmalphur) on 2026-10-15T15:53:08Z. --- Independent Linux validation of head `bca123a7b9597408ba7e6d0d1fc6b89872831a37`, using CPython 3.14.7. - `python3 tools/tests/test_package_release.py`: 27 tests, 24 passed and 3 platform-specific skips. - Running the new alias regression against the unmodified tool from `main` at `0c4816f6119e5dc1208b16b25a171d1c88aa18f4` produces 9 failed subcases, no errors or skips. - Separate real CLI checks confirm that shared outputs preserve an existing full changelog, normalized aliases to a nonexistent output create no file, and a dangling output symlink is preserved without creating its target. With distinct outputs, oversized full notes are retained and the shortened body is correct. - Locally merged this head with that `main` in an isolated checkout. All 27 tests still pass with the same 3 skips; conventions and whitespace checks pass. This validates release-note tooling only; no native runtime or GPU tests were run. AI-assisted: yes (Codex).
jotitadev commented 2026-10-15 17:39:27 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-15T17:39:27Z.

Review: COMMENTED


The new test does not run on Python 3.9, which is the python3 that ships with Xcode on macOS.

Machine: Apple M2 Max, macOS 27.2, /usr/bin/python3 3.9.6 and Homebrew Python 3.14. Head bca123a7b applied to main 03c4cb5e7.

test_aliased_paths_preserve_input_and_existing_outputs errors on the three hardlink subtests:

paths[second].hardlink_to(paths[first])
AttributeError: 'PosixPath' object has no attribute 'hardlink_to'

Path.hardlink_to was added in Python 3.10. os.link(paths[first], paths[second]) does the same thing, and os is already imported. With that one-line change, the test passes on 3.9.6, and on 3.14 it passes either way.

The fix itself works on 3.9. On APFS, which ignores case, I also tried case-only aliases of the input (notes.json given as NOTES.json and Notes.JSON for the body output). Both are refused with must be distinct files and the input is unchanged: resolve() keeps the spelling it is given, but samefile catches it.

On main, ReleaseNotesTests.test_full_notes_are_preserved_in_asset already errors on 3.9 for a different reason, unrelated to this PR.

Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5537434944 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6424#pullrequestreview-5537434944). Originally posted by [jotitadev](https://github.com/jotitadev) on 2026-10-15T17:39:27Z. **Review:** COMMENTED --- The new test does not run on Python 3.9, which is the `python3` that ships with Xcode on macOS. Machine: Apple M2 Max, macOS 27.2, `/usr/bin/python3` 3.9.6 and Homebrew Python 3.14. Head bca123a7b applied to `main` 03c4cb5e7. `test_aliased_paths_preserve_input_and_existing_outputs` errors on the three `hardlink` subtests: ``` paths[second].hardlink_to(paths[first]) AttributeError: 'PosixPath' object has no attribute 'hardlink_to' ``` `Path.hardlink_to` was added in Python 3.10. `os.link(paths[first], paths[second])` does the same thing, and `os` is already imported. With that one-line change, the test passes on 3.9.6, and on 3.14 it passes either way. The fix itself works on 3.9. On APFS, which ignores case, I also tried case-only aliases of the input (`notes.json` given as `NOTES.json` and `Notes.JSON` for the body output). Both are refused with `must be distinct files` and the input is unchanged: `resolve()` keeps the spelling it is given, but `samefile` catches it. On `main`, `ReleaseNotesTests.test_full_notes_are_preserved_in_asset` already errors on 3.9 for a different reason, unrelated to this PR. Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.
jotitadev commented 2026-10-15 18:26:41 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-15T18:26:41Z.

Review: COMMENTED


Re-checked head 0be11ff1a (merged onto main b7cedd900) on an Apple M2 Max: the os.link change fixes it. test_aliased_paths_preserve_input_and_existing_outputs now passes with the Xcode Python 3.9.6 on arm64 and on x86_64 under Rosetta, and with Python 3.14.7 on arm64. Applying only the test on main still fails all 9 subtests, so it guards the fix.

The 4 remaining ReleaseNotesTests errors on 3.9 are the existing write_text(newline=) calls in prepare_release_notes.py:31-32. They fail the same way on main and are not from this PR.

Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5538008478 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6424#pullrequestreview-5538008478). Originally posted by [jotitadev](https://github.com/jotitadev) on 2026-10-15T18:26:41Z. **Review:** COMMENTED --- Re-checked head `0be11ff1a` (merged onto `main` b7cedd900) on an Apple M2 Max: the `os.link` change fixes it. `test_aliased_paths_preserve_input_and_existing_outputs` now passes with the Xcode Python 3.9.6 on arm64 and on x86_64 under Rosetta, and with Python 3.14.7 on arm64. Applying only the test on `main` still fails all 9 subtests, so it guards the fix. The 4 remaining `ReleaseNotesTests` errors on 3.9 are the existing `write_text(newline=)` calls in `prepare_release_notes.py:31-32`. They fail the same way on `main` and are not from this PR. Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.
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!6424
No description provided.