Repository navigation
fix(kvstoreentry): route --dir output through the configured writer - #1975
Tyagiquamar wants to merge 3 commits into
Conversation
Verbose per-file names and per-file upload errors were printed with fmt.Println/fmt.Printf, which bypass the out io.Writer supplied by the caller. Use fmt.Fprintln(out, ...) and fmt.Fprintf(out, ...) so all command output goes to the same writer.
…r-output-writer # Conflicts: # CHANGELOG.md
There was a problem hiding this comment.
Warning
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Copilot review overview
1 open issue
What changed in this PR
Ensures kv-store-entry create --dir routes verbose per-file output and per-file error details through the configured out io.Writer (instead of bypassing it via process stdout), and adds regression tests + changelog entry.
Changes:
- Switched two
ProcessDiroutput call sites fromfmt.Println/Printftofmt.Fprintln/Fprintf(out, ...). - Added Go CLI scenario tests to validate verbose filenames and per-file errors are emitted to the configured writer.
- Added a changelog entry under “Bug Fixes”.
| File | Description |
|---|---|
| pkg/commands/kvstoreentry/create.go | Routes verbose filenames and per-file upload error details through the provided out writer. |
| pkg/commands/kvstoreentry/kvstoreentry_test.go | Adds regression scenarios to ensure output is captured via the configured writer for --dir. |
| CHANGELOG.md | Documents the bug fix in the changelog per repository requirements. |
Review effort: Lite
| } | ||
| return errors.New("invalid request") | ||
| }, | ||
| }, |
|
These changes are internal cleanups that users won't see: "out" is just stdout, wrapped so ANSI color codes display correctly on older Windows consoles. The filenames and error lines printed here have no color codes, so the output is identical, including when it's redirected or piped. Still, it's nice to clean up the last two places in the commands that call fmt.Println()/fmt.Printf() directly, for consistency and testability. Could you drop the CHANGELOG entry, since this isn't a user-facing change? I'll add the Skip-Changelog label so CI stays green. |
|
I don't think the tests are necessary. Just update the 2 relevant lines. |
jedisct1
left a comment
There was a problem hiding this comment.
Just update the Print() calls to print via "out".
|
Thanks for the contribution! This pull request doesn't follow our pull request template:
Please edit the description to use the template. If it is still missing after 3 days, this pull request will be closed automatically. |

Summary
Route the two remaining
kv-store-entry create --dirprint calls through the command's configuredout io.Writer.This is an internal consistency and testability cleanup. It does not change the command's user-visible output.
Root Cause & Problem
CreateCommand.ProcessDirreceives an output writer and uses it for the spinner, section breaks, and final status. Its verbose filename loop and per-file error loop were the two exceptions, using package-levelfmt.Printlnandfmt.Printfinstead.Technical Solution
fmt.Println(filename)withfmt.Fprintln(out, filename).fmt.Printfcall withfmt.Fprintf(out, ...).Test Plan
Validated with Go 1.26.10:
gofmton the affected package filesgo test -p 1 ./pkg/commands/kvstoreentry -count=1go vet ./pkg/commands/kvstoreentryChecklist