From 46813ed84d6c925351056afebb719ab84ec2dd29 Mon Sep 17 00:00:00 2001 From: Mukul Date: Mon, 20 Jul 2026 22:19:02 +0530 Subject: [PATCH] Do not duplicate top-level command errors onto stdout; exit 1 not 255 cmd.Execute printed the command error a second time to stdout via fmt.Println and exited with -1 (which surfaces as 255). RootCmd sets neither SilenceErrors nor SilenceUsage, so cobra already prints the error and usage hint to stderr; the extra print leaked a duplicate onto stdout, corrupting piped output for mistyped commands. Drop the extra print and exit with the conventional failure code 1. Signed-off-by: Mukul --- cmd/dapr.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/cmd/dapr.go b/cmd/dapr.go index 203af70eef..b9e41d4176 100644 --- a/cmd/dapr.go +++ b/cmd/dapr.go @@ -78,8 +78,10 @@ func Execute(version, apiVersion string) { cobra.OnInitialize(initConfig) if err := RootCmd.Execute(); err != nil { - fmt.Println(err) - os.Exit(-1) + // cobra already prints the error and usage hint to stderr, so avoid + // printing it a second time to stdout. Exit 1 rather than -1 (which + // surfaces as 255) to follow the conventional CLI failure code. + os.Exit(1) } }