From 7c0a5f9c048a2702b696deb7594c39f2909b7922 Mon Sep 17 00:00:00 2001 From: Mukul Date: Mon, 20 Jul 2026 03:51:07 +0530 Subject: [PATCH] Route error and warning status messages to stderr Twelve call sites printed FailureStatusEvent to stdout, and dapr list -k printed its namespace deprecation warning to stdout ahead of the requested output, which corrupts 'dapr list -k -o json' (#1015). Errors-to-stderr is existing project policy (#748); these sites crept back in over time. The renew-certificate sites are intentionally left out because #1670 already moves them. Fixes #1015 Signed-off-by: Mukul --- cmd/init.go | 2 +- cmd/list.go | 8 ++++---- cmd/uninstall.go | 2 +- cmd/version.go | 2 +- cmd/workflow/raiseevent.go | 2 +- cmd/workflow/rerun.go | 2 +- cmd/workflow/resume.go | 2 +- cmd/workflow/run.go | 2 +- cmd/workflow/suspend.go | 2 +- cmd/workflow/terminate.go | 2 +- 10 files changed, 13 insertions(+), 13 deletions(-) diff --git a/cmd/init.go b/cmd/init.go index 80d05443fb..528a1bfe36 100644 --- a/cmd/init.go +++ b/cmd/init.go @@ -175,7 +175,7 @@ dapr init --redis-stack } if !utils.IsValidContainerRuntime(containerRuntime) { - print.FailureStatusEvent(os.Stdout, "Invalid container runtime. Supported values are docker and podman.") + print.FailureStatusEvent(os.Stderr, "Invalid container runtime. Supported values are docker and podman.") os.Exit(1) } diff --git a/cmd/list.go b/cmd/list.go index 1d7a6047cd..a54591be78 100644 --- a/cmd/list.go +++ b/cmd/list.go @@ -34,13 +34,13 @@ func outputList(list interface{}, length int) { if outputFormat == "json" || outputFormat == "yaml" { err := utils.PrintDetail(os.Stdout, outputFormat, list) if err != nil { - print.FailureStatusEvent(os.Stdout, err.Error()) + print.FailureStatusEvent(os.Stderr, err.Error()) os.Exit(1) } } else { table, err := gocsv.MarshalString(list) if err != nil { - print.FailureStatusEvent(os.Stdout, err.Error()) + print.FailureStatusEvent(os.Stderr, err.Error()) os.Exit(1) } @@ -72,13 +72,13 @@ dapr list -k --all-namespaces `, PreRun: func(cmd *cobra.Command, args []string) { if outputFormat != "" && outputFormat != "json" && outputFormat != "yaml" && outputFormat != "table" { - print.FailureStatusEvent(os.Stdout, "An invalid output format was specified.") + print.FailureStatusEvent(os.Stderr, "An invalid output format was specified.") os.Exit(1) } }, Run: func(cmd *cobra.Command, args []string) { if kubernetesMode { - print.WarningStatusEvent(os.Stdout, "In future releases, this command will only query the \"default\" namespace by default. Please use the --namespace flag for a specific namespace, or the --all-namespaces (-A) flag for all namespaces.") + print.WarningStatusEvent(os.Stderr, "In future releases, this command will only query the \"default\" namespace by default. Please use the --namespace flag for a specific namespace, or the --all-namespaces (-A) flag for all namespaces.") if allNamespaces { resourceNamespace = meta_v1.NamespaceAll } else if resourceNamespace == "" { diff --git a/cmd/uninstall.go b/cmd/uninstall.go index 3ecb638064..af4c627bdf 100644 --- a/cmd/uninstall.go +++ b/cmd/uninstall.go @@ -80,7 +80,7 @@ dapr uninstall --runtime-path err = kubernetes.Uninstall(uninstallNamespace, uninstallAll, uninstallDev, timeout) } else { if !utils.IsValidContainerRuntime(uninstallContainerRuntime) { - print.FailureStatusEvent(os.Stdout, "Invalid container runtime. Supported values are docker and podman.") + print.FailureStatusEvent(os.Stderr, "Invalid container runtime. Supported values are docker and podman.") os.Exit(1) } print.InfoStatusEvent(os.Stdout, "Removing Dapr from your machine...") diff --git a/cmd/version.go b/cmd/version.go index 74f9e088c7..9fabc9adab 100644 --- a/cmd/version.go +++ b/cmd/version.go @@ -36,7 +36,7 @@ dapr version --output json `, Run: func(cmd *cobra.Command, args []string) { if output != "" && output != "json" { - print.FailureStatusEvent(os.Stdout, "An invalid output format was specified.") + print.FailureStatusEvent(os.Stderr, "An invalid output format was specified.") os.Exit(1) } switch output { diff --git a/cmd/workflow/raiseevent.go b/cmd/workflow/raiseevent.go index 6a40cc9fc8..9b210616a2 100644 --- a/cmd/workflow/raiseevent.go +++ b/cmd/workflow/raiseevent.go @@ -58,7 +58,7 @@ var RaiseEventCmd = &cobra.Command{ } if err = workflow.RaiseEvent(ctx, opts); err != nil { - print.FailureStatusEvent(os.Stdout, err.Error()) + print.FailureStatusEvent(os.Stderr, err.Error()) os.Exit(1) } diff --git a/cmd/workflow/rerun.go b/cmd/workflow/rerun.go index 2d45290ba7..3a049b8f54 100644 --- a/cmd/workflow/rerun.go +++ b/cmd/workflow/rerun.go @@ -58,7 +58,7 @@ var ReRunCmd = &cobra.Command{ id, err := workflow.ReRun(ctx, opts) if err != nil { - print.FailureStatusEvent(os.Stdout, err.Error()) + print.FailureStatusEvent(os.Stderr, err.Error()) os.Exit(1) } diff --git a/cmd/workflow/resume.go b/cmd/workflow/resume.go index 68085181cb..6d60e17af8 100644 --- a/cmd/workflow/resume.go +++ b/cmd/workflow/resume.go @@ -47,7 +47,7 @@ var ResumeCmd = &cobra.Command{ } if err = workflow.Resume(ctx, opts); err != nil { - print.FailureStatusEvent(os.Stdout, err.Error()) + print.FailureStatusEvent(os.Stderr, err.Error()) os.Exit(1) } diff --git a/cmd/workflow/run.go b/cmd/workflow/run.go index 6a26b6ed3d..9baee0fc82 100644 --- a/cmd/workflow/run.go +++ b/cmd/workflow/run.go @@ -60,7 +60,7 @@ var RunCmd = &cobra.Command{ id, err := workflow.Run(ctx, opts) if err != nil { - print.FailureStatusEvent(os.Stdout, err.Error()) + print.FailureStatusEvent(os.Stderr, err.Error()) os.Exit(1) } diff --git a/cmd/workflow/suspend.go b/cmd/workflow/suspend.go index 1023a58bb9..ba39bbd084 100644 --- a/cmd/workflow/suspend.go +++ b/cmd/workflow/suspend.go @@ -47,7 +47,7 @@ var SuspendCmd = &cobra.Command{ } if err = workflow.Suspend(ctx, opts); err != nil { - print.FailureStatusEvent(os.Stdout, err.Error()) + print.FailureStatusEvent(os.Stderr, err.Error()) os.Exit(1) } diff --git a/cmd/workflow/terminate.go b/cmd/workflow/terminate.go index 2c4823932e..670fe37b49 100644 --- a/cmd/workflow/terminate.go +++ b/cmd/workflow/terminate.go @@ -52,7 +52,7 @@ var TerminateCmd = &cobra.Command{ } if err = workflow.Terminate(ctx, opts); err != nil { - print.FailureStatusEvent(os.Stdout, err.Error()) + print.FailureStatusEvent(os.Stderr, err.Error()) os.Exit(1) }