Skip to content

fix(tools): report configure_seed symbolic link loops as usage errors - #12614

Merged
oneandonlydean merged 1 commit into
boykopovar:mainfrom
rooklz:fix/configure-seed-symlink-loop
Nov 2, 2026
Merged

oneandonlydean merged 1 commit into
boykopovar:mainfrom
rooklz:fix/configure-seed-symlink-loop

Conversation

@rooklz

@rooklz rooklz commented Oct 28, 2026

Copy link
Copy Markdown
Contributor

What

configure_seed checks that the seed output isn't the input cache by comparing Path.resolve() of both, and write_seed resolves the output again. When either path is a symbolic link loop (ln -s loop loop), resolve() raises RuntimeError("Symlink loop ...") on Python 3.9–3.12. That isn't an OSError, so the tool prints a traceback and exits 1 instead of giving its usage error.

On 3.13+ resolve() doesn't raise, and there is a second problem. With a looping seed output, destination.exists() returns False, so write_seed treats the loop as a missing file, os.replace swaps a regular file in for the link, and the tool exits 0 with 0 check results. So the user's link is silently replaced.

Both checks now use os.path.realpath, which returns the looping path on every version without raising. write_seed calls stat() and treats only FileNotFoundError as "no existing seed", so a loop raises ELOOP through the existing except OSError handler. Now a looping cache or seed exits 2 with configure_seed.py: error: <path>: [Errno 62] Too many levels of symbolic links, and nothing is written or replaced. This is the same fix #12331 and #12338 made for pad_timeline and prepare_release_notes.

Tested

macOS arm64. New ConfigureSeedPathTests.test_symbolic_link_loops_are_reported_without_a_traceback runs with the loop as the seed output and again with the loop as the input cache. It checks for exit 2, empty stdout, the path in stderr, no traceback, the link left in place, no seed file created and the cache unchanged:

  • main source: both subtests FAIL on 3.9.6, 3.12, 3.13 and 3.15 (a traceback on ≤3.12; on 3.13+ the link is replaced and the tool exits 0)
  • this branch: tools.tests.test_configure_seed OK on 3.9.6, 3.12, 3.13, 3.14 and 3.15
  • mutants, each reverting one hunk: write_seed back to resolve() fails on 3.9 (passes on 3.13, where only the stat() hunk matters). The alias check back to resolve() fails on 3.9. exists() back in place of stat() fails on both 3.9 and 3.13.
  • relinker-only build, ctest 392/392 on main c920762
  • check_conventions --base upstream/main clean. pr_overlap found no overlap. fix(tools): parse quoted CMake cache check names in configure_seed #12174 (quoted cache names, same file) changes only the checks() parser lines, and git merge-tree with this branch is clean.

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 (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

@JJenkx

JJenkx commented Oct 29, 2026

Copy link
Copy Markdown
Contributor

Windows run of this head (1ff12a6f7c), merged onto main 52c09d567d (clean merge, local only). Windows 11 Enterprise 10.0.22621, Python 3.15.1, python -m unittest tools/tests/test_configure_seed.py; this machine can create symbolic links.

  • This PR: 28 tests pass, 3 of 3 runs. 2 are skipped here by their own conditions, none of them new: test_existing_modes_and_new_file_umask_are_preserved (skip reason: "requires POSIX file modes"); test_failed_write_preserves_existing_seed_and_allows_retry (skip reason: "requires POSIX file size limits").
  • Negative control: with tools/configure_seed.py put back to main's version and this PR's tests kept, the new test test_symbolic_link_loops_are_reported_without_a_traceback fails. The other test definitions this diff adds or moves pass with main's code as well: test_filters_do_not_allow_overwriting_cache.

AI-assisted: yes (Claude Code).

@THEMANnt THEMANnt left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 1ff12a6f7cf2eca3df75e046a68cca1a29fe808e against c9207624bc0ac70bac2878062bd27bcaa44d109f. Seed output resolution uses non-strict real paths followed by explicit stat/write errors, while preserving cache/output alias checks and staged seed writes. No actionable finding in this scoped review.

Windows/Python 3.11 validation: head 23 passed, 5 skipped; baseline 23 passed, 4 skipped. Independent real Windows junction-loop CLI control: head exits 2 without traceback; baseline exits 1 with RuntimeError. Input cache bytes are unchanged and the verified junction is removed. Ordinary symlink/permission tests remain skipped; their old-code control passes due to those skips and is not counted as proof.

@rooklz
rooklz force-pushed the fix/configure-seed-symlink-loop branch 2 times, most recently from df28236 to f1b3ad6 Compare October 30, 2026 11:26
@malekaifa

Copy link
Copy Markdown
Contributor

Coordination note with #13278: current #12614 adds one new subprocess call in est_symbolic_link_loops_are_reported_without_a_traceback using capture_output=True, text=True. #13278 fixes the same test module's configure_seed subprocess decoding by using encoding='utf-8', because the tool explicitly emits UTF-8 and locale decoding fails under paths such as C:\tmp\e_é on ACP1252 Windows. The two branches merge cleanly, so there is no landing-order conflict; please carry the same encoding='utf-8' adjustment into this added subprocess if #12614 lands after #13278. This is coordination only, not a functional objection to the symlink-loop fix.

@rooklz
rooklz force-pushed the fix/configure-seed-symlink-loop branch 3 times, most recently from b46dce8 to 1ab2447 Compare October 31, 2026 01:18
@rooklz
rooklz force-pushed the fix/configure-seed-symlink-loop branch from 1ab2447 to b881eeb Compare October 31, 2026 01:44
@oneandonlydean
oneandonlydean merged commit 13f44d1 into boykopovar:main Nov 2, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants