fix: use existing formatSize function, size regards model files only#988
fix: use existing formatSize function, size regards model files only#988KeeTraxx wants to merge 3 commits into
Conversation
There was a problem hiding this comment.
Code Review
This pull request consolidates size formatting logic by exporting and reusing FormatSize from the format package, and updates the search backend resolution to filter model files before calculating total size. The review feedback correctly identifies that returning "0.00B" for non-positive sizes is misleading compared to the original "n/a" representation, and points out that an error returned by FilterModelFiles is currently being silently ignored.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
There was a problem hiding this comment.
Hey - I've found 1 issue, and left some high level feedback:
- Changing zero/negative size formatting from "n/a" to "0.00B" alters the semantics for existing callers; consider confirming that all consumers (especially CLI output) expect this new representation or mapping it at the call site if needed.
- In
backend_resolution.gothe error fromdistributionhf.FilterModelFilesis ignored; if filtering can fail in meaningful ways, it may be safer to propagate or handle that error rather than silently falling back.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Changing zero/negative size formatting from "n/a" to "0.00B" alters the semantics for existing callers; consider confirming that all consumers (especially CLI output) expect this new representation or mapping it at the call site if needed.
- In `backend_resolution.go` the error from `distributionhf.FilterModelFiles` is ignored; if filtering can fail in meaningful ways, it may be safer to propagate or handle that error rather than silently falling back.
## Individual Comments
### Comment 1
<location path="cmd/cli/search/backend_resolution.go" line_range="95-96" />
<code_context>
return backendUnknown, 0, err
}
- return backendFromRepoFiles(repoFiles), distributionhf.TotalSize(repoFiles), nil
+ modelFiles, _ := distributionhf.FilterModelFiles(repoFiles)
+ return backendFromRepoFiles(repoFiles), distributionhf.TotalSize(modelFiles), nil
}
</code_context>
<issue_to_address>
**issue (bug_risk):** Swallowing the error from `FilterModelFiles` can lead to incorrect size calculation or mask resolution issues.
The error from `FilterModelFiles` is ignored, yet `TotalSize` is still computed from `modelFiles`. If filtering fails or returns a partial result, `Resolve` may return `nil` with a zero or incomplete size, making it hard to distinguish between "no model files" and "failed to determine model files" and potentially under-reporting sizes. Please propagate the error, or at least fall back to `repoFiles` for size computation when filtering fails.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Follow up PR for #985
Fixes comments from @doringeman
Added additional tests.