fix: normalize uid/gid/perms keys in _stat_for before special handling#99
Draft
Koan-Bot wants to merge 1 commit intocpan-authors:mainfrom
Draft
Conversation
stat_as_*(st_uid => 42) and stat_as_*(ST_GID => 7) silently dropped
the values because the uid/gid handlers checked $opts->{uid} directly,
before the normalization loop that strips the st_ prefix. The perms
handler had the same issue.
Move key normalization and validation to the top of _stat_for so all
handlers operate on canonical lowercase keys. This ensures st_uid,
ST_UID, st_gid, ST_GID, Perms, etc. all route through the correct
handlers (including getpwnam/getgrnam resolution for non-numeric values).
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
_stat_for()now normalizes all option keys (lowercase + stripst_prefix) before processing, ensuringuid,gid, andpermshandlers work with all key variants.Why
stat_as_file(st_uid => 42),stat_as_file(ST_GID => 7), etc. silently dropped values. Theuid/gidhandlers checked$opts->{uid}directly, but key normalization happened in a separate loop afterward — sost_uidnever reached thegetpwnamresolution path.This was a known gap noted in learnings but not yet fixed. Since
st_uidandst_gidmirror real stat struct field names, users naturally try them.How
Moved key validation and normalization to a single upfront pass that builds a
%normhash with canonical keys. All downstream handlers (perms,uid,gid,%name2ixloop) now operate on%norminstead of raw$opts.Testing
t/stat-key-normalization.tcoveringst_uid,ST_UID,st_gid,ST_GID,Perms🤖 Generated with Claude Code
Quality Report
Changes: 2 files changed, 79 insertions(+), 38 deletions(-)
Code scan: clean
Tests: passed (0 Tests)
Branch hygiene: clean
Generated by Kōan post-mission quality pipeline