fix(cli): surface stderr warnings on non-failing commands#6216
fix(cli): surface stderr warnings on non-failing commands#6216devantler wants to merge 2 commits into
Conversation
The error handler captures a command's stderr into an in-memory buffer for the whole run so it can normalize a failing command's output into the returned error. On the success path that buffer was discarded, so every warning a command wrote to stderr during a successful run — Helm-render degradations, --include-crd-schemas "skipped CRD schema" notices, CEL rule warnings — was silently dropped and never reached the user. In-process command tests never caught it because they capture stderr with their own buffer, not through the executor. Flush the captured buffer to the real stderr on the success branch (an empty buffer is a no-op, so silent commands are unaffected). The error-normalization path is untouched. Adds a regression test asserting a warning from a succeeding command reaches stderr. Fixes #6215 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
User-evaluation record. Built the branch binary and ran RED/GREEN unit test added ( |
✅MegaLinter analysis: Success✅ Linters with no issuesactionlint, bash-exec, git_diff, hadolint, jscpd, jsonlint, lychee, markdown-table-formatter, markdownlint, prettier, prettier, shellcheck, shfmt, stylelint, syft, trivy-sbom, trufflehog, v8r, v8r, yamllint Notices📣 MegaLinter 9.5.0 is out! Discover the new features and security recommendations in the release announcement. (Skip this info by defining See detailed reports in MegaLinter artifacts
|
Code Coverage OverviewLanguages: Go Go / code-coverage/goThe overall coverage in the branch remains at 67%, unchanged from the branch. Show a code coverage summary of the most impacted files.
Updated |
@codex review |
1 similar comment
@codex review |
Codex did not produce a review artifact ~22 min after two requests (lane stall); falling back to CodeRabbit for this PR. @coderabbitai review |
|
🐇🔎 ✅ Action performedReview finished.
|
📝 WalkthroughWalkthrough
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ce95824e73
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Extend the success-path flush to non-failing custom-exit-code results (e.g. DriftExitError from `cluster diff --exit-code`), which main.go surfaces as a process exit code without printing — so their captured warnings were still discarded. Adds a RED/GREEN regression test and extracts a shared flushWarnings helper. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Review note on the custom-exit flush ( 1. The custom-exit flush also surfaces Cobra's own error line. The root command sets 2. Finding 2 (long-running commands) is still open. Warnings are replayed only after Both fall out cleanly if the executor stops capturing and lets warnings flow straight to stderr (live), normalizing the error from the returned |

Why
Warnings that
ksailcommands write while not failing — "skipped Helm render …" degradations, "skipped CRD schema …" notices, CEL rule warnings — never reached users. The error handler captured all stderr to normalize failures and then discarded it whenever the command did not fail, so these intentional, user-facing warnings were silently dropped.What
Flush the captured stderr to the real terminal for every non-failing run — both plain success (
nil) and custom exit-code results such ascluster diff --exit-codedetecting drift (which main.go surfaces as an exit code and prints no error). Empty buffer ⇒ no-op, so silent commands are unaffected; the failure-normalization path is untouched. Verified with the real binary: the Helm-render degradation warning now appears. Unblocks every degradation/CRD/CEL warning across the CLI.Fixes #6215