Skip to content

fix: croak on I/O errors in Snapshot.pm#19

Draft
Koan-Bot wants to merge 1 commit intoPerl-Toolchain-Gang:mainfrom
Koan-Bot:koan.atoomic/snapshot-croak-on-io-errors
Draft

fix: croak on I/O errors in Snapshot.pm#19
Koan-Bot wants to merge 1 commit intoPerl-Toolchain-Gang:mainfrom
Koan-Bot:koan.atoomic/snapshot-croak-on-io-errors

Conversation

@Koan-Bot
Copy link

@Koan-Bot Koan-Bot commented Mar 19, 2026

What

Replace silent early-returns with croak() in Snapshot.pm so callers can distinguish I/O errors from empty/successful results.

Why

Three error paths silently swallowed failures:

  • __get_directory_names(): opendir failure returned () — identical to an empty directory
  • __vms_untargz(): open/close failures returned 0 — identical to a command failure

This made debugging I/O issues nearly impossible since errors were invisible to callers.

How

Replaced return () / return 0 with Carp::croak() including the path and $!, matching the existing error pattern used elsewhere in _extract_archive() (lines 128-131).

Testing

  • New t/syncer_snap_croak.t verifies __get_directory_names croaks on nonexistent dir and succeeds on valid dir
  • Existing t/syncer_snap.t still passes

🤖 Generated with Claude Code


Quality Report

Changes: 2 files changed, 45 insertions(+), 3 deletions(-)

Code scan: clean

Tests: skipped

Branch hygiene: clean

Generated by Kōan post-mission quality pipeline

opendir failure in __get_directory_names() silently returned an empty
list, making I/O errors indistinguishable from genuinely empty
directories. Similarly, open/close failures in __vms_untargz() silently
returned 0, hiding write errors from callers.

All three paths now croak() with descriptive messages including the
errno, consistent with the existing error-handling pattern in
_extract_archive().

Co-Authored-By: Claude Opus 4.6 <[email protected]>
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