Skip to content

fix: validate symlink target is defined before creating mock#383

Draft
Koan-Bot wants to merge 1 commit intocpan-authors:mainfrom
atoomic:koan.atoomic/symlink-undef-oldname
Draft

fix: validate symlink target is defined before creating mock#383
Koan-Bot wants to merge 1 commit intocpan-authors:mainfrom
atoomic:koan.atoomic/symlink-undef-oldname

Conversation

@Koan-Bot
Copy link
Copy Markdown
Contributor

@Koan-Bot Koan-Bot commented Apr 22, 2026

What

Validates that $oldname (symlink target) is defined in __symlink(), matching the existing $newname check and __link()'s behavior.

Why

symlink(undef, '/mocked/path') silently corrupted mock state: mode was changed to S_IFLNK and timestamps were updated, but readlink was set to undef — so exists() returned false and the mock was in an inconsistent state. Real Perl warns about uninitialized values and returns false with ENOENT.

How

Changed the !defined $newname guard to !defined $oldname || !defined $newname. One-line fix in __symlink().

Testing

  • New test: symlink(undef, $path) returns 0, sets $! = ENOENT, warns, and does not corrupt mock
  • New test: symlink($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

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

1 participant