fix: validate symlink target is defined before creating mock#383
Draft
Koan-Bot wants to merge 1 commit intocpan-authors:mainfrom
Draft
fix: validate symlink target is defined before creating mock#383Koan-Bot wants to merge 1 commit intocpan-authors:mainfrom
Koan-Bot wants to merge 1 commit intocpan-authors:mainfrom
Conversation
symlink(undef, $path) on a mocked path silently set readlink to undef, corrupting the mock: mode was changed to S_IFLNK but exists() returned false. Now both arguments are validated (matching __link's behavior). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.
What
Validates that
$oldname(symlink target) is defined in__symlink(), matching the existing$newnamecheck and__link()'s behavior.Why
symlink(undef, '/mocked/path')silently corrupted mock state: mode was changed toS_IFLNKand timestamps were updated, butreadlinkwas set toundef— soexists()returned false and the mock was in an inconsistent state. Real Perl warns about uninitialized values and returns false withENOENT.How
Changed the
!defined $newnameguard to!defined $oldname || !defined $newname. One-line fix in__symlink().Testing
symlink(undef, $path)returns 0, sets$! = ENOENT, warns, and does not corrupt mocksymlink($path, undef)(existing behavior, now tested)🤖 Generated with Claude Code
Quality Report
Changes: 2 files changed, 29 insertions(+), 1 deletion(-)
Code scan: clean
Tests: passed (OK)
Branch hygiene: clean
Generated by Kōan post-mission quality pipeline