Repository navigation
fix(tools): edit a symlink's target instead of replacing the link - #6358
Merged
VascoSch92 merged 2 commits intoNov 2, 2026
Merged
Conversation
Closed
75 of 86 tasks
VascoSch92
approved these changes
Nov 2, 2026
VascoSch92
left a comment
Member
There was a problem hiding this comment.
Thanks! I checked the test fails without the fix, and tried relative links, chained links, undo through a link and create on a dangling link. The link survives and the target keeps its permissions.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
HUMAN:
Fixed the symlink-replacement bug from #6348. I reviewed the diff and the test; editing through a symlink must keep the link and edit its target.
AGENT:
Why
FileEditor._atomic_writerenamed a temp file ontopathwithPath.replace, and a rename onto a symlink path replaces the link itself with a regular file. Any edit (str_replace,insert,create) performed through a symlink therefore destroyed the link and silently rewrote the wrong file, leaving the original target untouched.Summary
_atomic_write, so the temp file is created beside — and renamed onto — the target, and the link survives. One change covers every command that routes throughwrite_file; atomicity is preserved relative to the target's directory.test_str_replace_through_symlink_edits_targetfrom theworktree-test-edge-casesbranch (commit f2fcf6e) without itsxfail(strict=True)marker, per the [Bug]: Edge-case tests expose ~70 bugs across the SDK, agent server, tools and workspaces #6348 menu's acceptance criteria.Issue Number
Part of #6348 (menu sub-item: "atomic write replaces a symlink with a regular file")
How to Test
Before this change the test fails (
link.txtis no longer a symlink andtarget.txtstill readshello); after, it passes — the link stays a symlink and the target readsbye— and the fulltests/tools/file_editor/suite is 168 passed / 1 skipped (platform) with no regression.ruff check/formaton the touched files are clean. The test usessymlink_or_skip, so it runs for real wherever symlink creation is permitted.Type
Notes
None.