Dedupe GetFilesWithSuffix and document hash struct precondition - #2690
abrarshivani wants to merge 2 commits into
Conversation
GetFilesWithSuffix appended a path once per matching suffix, so a file that matched more than one of the provided suffixes was returned multiple times. Break after the first matching suffix so each file is returned at most once; this is behavior-identical for non-overlapping suffixes (the only current caller passes yaml/yml/json). Add a test asserting the single result. Also document that GetObjectHashIgnoreEmptyKeys requires a struct (or pointer to struct) and panics on other kinds, matching what all callers already pass. Signed-off-by: Abrar Shivani <ashivani@nvidia.com>
Cover the break-on-first-match path fully: order-independence, single-of-many match, multiple overlapping-match files, non-matching exclusion, and recursion. Signed-off-by: Abrar Shivani <ashivani@nvidia.com>
90b2ccd to
180a827
Compare
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: QUIET Plan: Advanced Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 8 included reviews per hour; 7 remain after this review. 📝 WalkthroughWalkthrough
Priority: ⬇️ Low Merge Risk: ⚪ Minimal · up to Matching files are now returned once when configured suffixes overlap, preventing duplicate downstream processing. The change is covered by focused tests and is ready to merge. Comment |
Description
Two small
internal/utilsproduction changes split out of the test-coverage PR #2656 (per review, so production behavior is tracked on its own):GetFilesWithSuffixappended a path once per matching suffix, so a file matching more than one of the provided suffixes was returned multiple times. It nowbreaks after the first matching suffix, returning each file at most once. Behavior-identical for the only current caller (which passes the non-overlappingyaml/yml/json); the change guards against future overlapping-suffix callers.GetObjectHashIgnoreEmptyKeys— documented (no behavior change) that the argument must be a struct or pointer-to-struct, and that other kinds/nil panic, since only struct fields can be enumerated. Matches what all callers already pass.A test asserts
GetFilesWithSuffixreturns a single entry for a file matching multiple suffixes.Checklist
make lint)make validate-generated-assets)make validate-modules)Testing