Skip to content

fix(kvstoreentry): route --dir output through the configured writer - #1975

Open
Tyagiquamar wants to merge 3 commits into
fastly:mainfrom
Tyagiquamar:fix/kvstoreentry-dir-output-writer
Open

Tyagiquamar wants to merge 3 commits into
fastly:mainfrom
Tyagiquamar:fix/kvstoreentry-dir-output-writer

Conversation

@Tyagiquamar

@Tyagiquamar Tyagiquamar commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Route the two remaining kv-store-entry create --dir print calls through the command's configured out io.Writer.

This is an internal consistency and testability cleanup. It does not change the command's user-visible output.

Root Cause & Problem

CreateCommand.ProcessDir receives 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-level fmt.Println and fmt.Printf instead.

Technical Solution

  • Replace fmt.Println(filename) with fmt.Fprintln(out, filename).
  • Replace the per-file fmt.Printf call with fmt.Fprintf(out, ...).
  • Keep the change limited to those two lines, as requested in review. No tests or changelog entry are included because the output is unchanged and the maintainer marked the changelog as unnecessary.

Test Plan

Validated with Go 1.26.10:

  • gofmt on the affected package files
  • go test -p 1 ./pkg/commands/kvstoreentry -count=1
  • go vet ./pkg/commands/kvstoreentry

Checklist

  • Followed the repository's contributing guidelines.
  • Checked for duplicate pull requests.
  • Ran the focused package checks locally.
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.
@Tyagiquamar
Tyagiquamar requested a review from a team as a code owner November 17, 2026 10:41
@Tyagiquamar
Tyagiquamar requested a review from jedisct1 November 17, 2026 10:41
Copilot AI balanced review requested due to automatic review settings November 30, 2026 16:02

Copilot AI 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.

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 ProcessDir output call sites from fmt.Println/Printf to fmt.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")
},
},
@jedisct1

Copy link
Copy Markdown
Contributor

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.

@jedisct1

Copy link
Copy Markdown
Contributor

I don't think the tests are necessary. Just update the 2 relevant lines.

@jedisct1 jedisct1 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Just update the Print() calls to print via "out".

@jedisct1 jedisct1 added the Skip-Changelog do not add a changelog entry for this change label Nov 30, 2026
@github-actions

github-actions Bot commented Dec 1, 2026

Copy link
Copy Markdown

Thanks for the contribution! This pull request doesn't follow our pull request template:

  • the ### Change summary section is missing
  • the All Submissions: checklist is missing

Please edit the description to use the template. If it is still missing after 3 days, this pull request will be closed automatically.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-template Skip-Changelog do not add a changelog entry for this change

3 participants