π€ Generated by the Daily AI Engineer
Evidence & problem
Every warning a command writes to its stderr during a successful run is silently discarded β it never reaches CLI users. This affects real, intentional warnings: workload validate/scan Helm-render degradations ("skipped Helm render β¦"), --include-crd-schemas "skipped CRD schema β¦" notices, and CEL rule warnings.
Reproduction: run ksail workload validate <dir> on a kustomization whose HelmRelease chart cannot be resolved offline (e.g. an unreachable oci:// source). Validation degrades gracefully and passes β but the "skipped Helm render β¦" warning that warnDegradations emits never appears on stderr. The in-process tests pass because they run the command with a captured buffer, so the bug is invisible to the test suite.
Root cause
pkg/cli/ui/errorhandler/executor.go redirects the command's stderr into an in-memory buffer for the whole run so it can normalize the final Cobra error message:
cmd.SetErr(&errBuf)
defer cmd.SetErr(originalErrWriter)
err := cmd.Execute()
if err == nil { return nil } // errBuf (incl. all warnings) discarded on success
On success errBuf is dropped, so every non-error stderr write made during the run is lost. The capture itself is intentional (it turns a failing command's stderr into the normalized CommandError), but it also swallows legitimate warnings.
Expected behaviour
Warnings/notices written to stderr during a successful run reach the real stderr. The error-normalization path (capture β normalize β single clean print) stays unchanged.
Candidate fix (small, low-risk)
On the success branch, flush the captured buffer to the original stderr writer before returning nil (empty buffer β no-op, so silent commands are unaffected). The error path is untouched. A regression test asserts a warning written by a succeeding command reaches the real stderr.
Acceptance criteria
Size: S. Impact: unblocks all degradation/CRD/CEL warnings across the CLI (they are correct but currently invisible).
Evidence & problem
Every warning a command writes to its stderr during a successful run is silently discarded β it never reaches CLI users. This affects real, intentional warnings:
workload validate/scanHelm-render degradations ("skipped Helm render β¦"),--include-crd-schemas"skipped CRD schema β¦" notices, and CEL rule warnings.Reproduction: run
ksail workload validate <dir>on a kustomization whose HelmRelease chart cannot be resolved offline (e.g. an unreachableoci://source). Validation degrades gracefully and passes β but the "skipped Helm render β¦" warning thatwarnDegradationsemits never appears on stderr. The in-process tests pass because they run the command with a captured buffer, so the bug is invisible to the test suite.Root cause
pkg/cli/ui/errorhandler/executor.goredirects the command's stderr into an in-memory buffer for the whole run so it can normalize the final Cobra error message:On success
errBufis dropped, so every non-error stderr write made during the run is lost. The capture itself is intentional (it turns a failing command's stderr into the normalizedCommandError), but it also swallows legitimate warnings.Expected behaviour
Warnings/notices written to stderr during a successful run reach the real stderr. The error-normalization path (capture β normalize β single clean print) stays unchanged.
Candidate fix (small, low-risk)
On the success branch, flush the captured buffer to the original stderr writer before returning nil (empty buffer β no-op, so silent commands are unaffected). The error path is untouched. A regression test asserts a warning written by a succeeding command reaches the real stderr.
Acceptance criteria
cmd.ErrOrStderr()by a command that returns nil reaches the real stderr.Size: S. Impact: unblocks all degradation/CRD/CEL warnings across the CLI (they are correct but currently invisible).