Skip to content

[Janitor] fix(cmd): use RunE to propagate write errors from version command#58

Draft
github-actions[bot] wants to merge 1 commit into
mainfrom
janitor/improve-error-handling-762b0fbc58988fa3
Draft

[Janitor] fix(cmd): use RunE to propagate write errors from version command#58
github-actions[bot] wants to merge 1 commit into
mainfrom
janitor/improve-error-handling-762b0fbc58988fa3

Conversation

@github-actions

@github-actions github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Previously, newVersionCmd used Run and silently discarded write errors with _, _. This meant that if writing to stdout failed (e.g. broken pipe), the command would exit 0 with no error message.

Changes:

  • Switch newVersionCmd from Run to RunE, wrapping any fmt.Fprintln error with context ("print version: %w")
  • Add TestVersionCommandPropagatesWriteError to exercise the error path, restoring internal/cmd coverage to 100% (total: 92.3%)

All tests pass, golangci-lint reports 0 issues.


🤖 This PR was created by the Janitor — an automated code-quality bot. Task: Improve error handling (Task 4).

Generated by Janitor · sonnet46 2M ·

Previously, newVersionCmd used Run and silently discarded write errors
with _, _. Switch to RunE so errors from fmt.Fprintln are wrapped and
returned to the caller, letting cobra report them and exit non-zero.

Also adds TestVersionCommandPropagatesWriteError to cover the error path,
restoring internal/cmd coverage to 100%.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants