Skip to content

fix: croak on unknown options in stat_as_* helpers#94

Merged
atoomic merged 1 commit intocpan-authors:mainfrom
Koan-Bot:koan.atoomic/validate-stat-helper-options
Apr 23, 2026
Merged

fix: croak on unknown options in stat_as_* helpers#94
atoomic merged 1 commit intocpan-authors:mainfrom
Koan-Bot:koan.atoomic/validate-stat-helper-options

Conversation

@Koan-Bot
Copy link
Copy Markdown
Contributor

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

What

Validates option keys in stat_as_* helpers — typos now croak instead of silently producing wrong stat arrays.

Why

stat_as_file(szie => 42) silently returns a stat array with size = 0 because the typo key is ignored during the %name2ix lookup. This produces subtle test failures where the stat array looks correct at first glance but has default zeros where specific values were intended.

How

  • Added a %known_opts set (perms, uid, gid + all %name2ix keys) in _stat_for()
  • Each option key is validated after normalization (lowercase + strip st_ prefix)
  • Unknown keys croak immediately with the offending key name
  • The mode key gets a specific helpful message pointing to perms
  • 6 new tests in stat-helpers-invalid-user-group.t covering typos, unknown keys, mode hint, and regression checks

Testing

Full test suite passes (make test).

🤖 Generated with Claude Code


Quality Report

Changes: 2 files changed, 36 insertions(+), 1 deletion(-)

Code scan: clean

Tests: passed (0 Tests)

Branch hygiene: clean

Generated by Kōan post-mission quality pipeline

Previously, typos like stat_as_file(szie => 42) were silently ignored,
producing stat arrays with default zeros — a subtle source of test
failures. Now _stat_for() validates all option keys against the known
set and croaks immediately on unknown keys.

The 'mode' key gets a specific hint pointing to 'perms' since the file
type bits are set automatically by the stat_as_* function.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@atoomic atoomic marked this pull request as ready for review April 23, 2026 07:17
@atoomic atoomic merged commit 8a1ffd4 into cpan-authors:main Apr 23, 2026
21 checks passed
@Koan-Bot Koan-Bot deleted the koan.atoomic/validate-stat-helper-options branch April 23, 2026 08:32
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.

2 participants