fix: cli stdout warnings corrupt redirected output#710
Merged
Justiceleeg merged 9 commits intomainfrom May 1, 2026
Merged
Conversation
This reverts commit 890004e.
Cobra's auto-emitted output (deprecation warnings, usage-on-error) was going to stdout, corrupting redirected structured output such as `cluster kubeconfig --stdout > kubeconfig.yaml`. Align with cobra's default by setting Out to stderr. Refs sc-136974
Move the kubeconfig success, backup-removal failure, and context-updated messages from stdout to stderr so they no longer corrupt the YAML payload when output is redirected. Also switch the --stdout data path from Println to Print to avoid an extra trailing newline. Refs sc-136974
The auto-discovery branch printed informational text to r.w (stdout) regardless of output format, breaking JSON parsers when running `release lint -o json` outside a configured project. Gate the discovery messages on table format, and have the empty-result early return emit a valid JSON payload so consumers always receive parseable output. Refs sc-136974
Logger TTY checks were hardcoded to os.Stdout.Fd(), so spinners fired even when the logger had been pointed at a non-TTY writer. Replace each call site with an isTTY helper that type-asserts the configured writer. Switch the two `release download` callers from os.Stdout to os.Stderr — the command's data path writes files to disk, so progress messages belong on stderr. Refs sc-136974
`app rm` shares its logger writer with structured output, so the fetch/delete spinners leaked into the JSON payload. Gate the spinner calls on `outputFormat == \"table\"` to keep the JSON output clean. Refs sc-136974
The previous patch broke spinners for any logger built from a tabwriter wrapping stdout: the type assertion to *os.File failed, so isTTY() always returned false. Capture the stdout TTY state once in Execute() and let callers thread it through with SetIsTerminal so wrapped writers still spin when stdout is a real terminal. Refs sc-136974
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 6c2f3f0. Configure here.
Setting cobra Out to stderr also redirected --help, breaking `replicated --help | grep ...` and `--help > help.txt`. Restore the CLI convention by overriding the root HelpFunc to write to stdout while leaving deprecation warnings and usage-on-error on stderr. Refs sc-136974
divolgin
approved these changes
May 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

https://app.shortcut.com/replicated/story/136974/cli-stdout-warnings-corrupt-redirected-output-e-g-replicated-cluster-kubeconfig-file