Skip to content

Dedupe GetFilesWithSuffix and document hash struct precondition - #2690

Open
abrarshivani wants to merge 2 commits into
NVIDIA:mainfrom
abrarshivani:utils-dedupe-getfiles
Open

abrarshivani wants to merge 2 commits into
NVIDIA:mainfrom
abrarshivani:utils-dedupe-getfiles

Conversation

@abrarshivani

@abrarshivani abrarshivani commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Description

Two small internal/utils production changes split out of the test-coverage PR #2656 (per review, so production behavior is tracked on its own):

  1. GetFilesWithSuffix appended a path once per matching suffix, so a file matching more than one of the provided suffixes was returned multiple times. It now breaks after the first matching suffix, returning each file at most once. Behavior-identical for the only current caller (which passes the non-overlapping yaml/yml/json); the change guards against future overlapping-suffix callers.
  2. 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 GetFilesWithSuffix returns a single entry for a file matching multiple suffixes.

Checklist

  • No secrets, sensitive information, or unrelated changes
  • Lint checks passing (make lint)
  • Generated assets in-sync (make validate-generated-assets)
  • Go mod artifacts in-sync (make validate-modules)
  • Test cases are added for new code paths

Testing

go test ./internal/utils/...
golangci-lint run ./internal/utils/...   # 0 issues (GOOS=linux)

Devin Review

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>
@coderabbitai

coderabbitai Bot commented Sep 9, 2026

Copy link
Copy Markdown

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: QUIET

Plan: Advanced

Run ID: 6a0913bb-86ca-4a02-9acd-7d287ea1d968

📥 Commits

Reviewing files that changed from the base of the PR and between 6e330ac and 180a827.

📒 Files selected for processing (2)
  • internal/utils/getfiles_dedup_test.go
  • internal/utils/utils.go

Included review availability: Your plan provides up to 8 included reviews per hour; 7 remain after this review.


📝 Walkthrough

Walkthrough

GetFilesWithSuffix now stops checking suffixes after the first match, so each file path appears once. New table-driven tests cover overlapping suffixes, suffix-order independence, non-matching files, multiple matching files, and subdirectories. GetObjectHashIgnoreEmptyKeys now documents its required argument types and panic conditions.

Priority: ⬇️ Low

Merge Risk: ⚪ Minimal · up to 180a8

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 @coderabbitai help to get the list of available commands.

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Devin Review

This branch has not been deployed

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

3 participants