redpanda icon indicating copy to clipboard operation
redpanda copied to clipboard

rpk: subcommands does not return "unknown command" error

Open r-vasquez opened this issue 1 year ago • 0 comments

Version & Environment

Redpanda version: (use rpk version): v24.1.2

What went wrong?

When running an unknown subcommand of an rpk subcommand, rpk won't return an "unknown command" error and exit with an error code 0:

$ rpk cluster foobar
Interact with a Redpanda cluster

Usage:
  rpk cluster [flags]
  rpk cluster [command]

Available Commands:
  config      Interact with cluster configuration properties
  [...]

Use "rpk cluster [command] --help" for more information about a command.

$ echo $?
0

What should have happened instead?

To return 1, and an error:

Error: unknown command "foobar" for "rpk cluster"

How to reproduce the issue?

  1. Steps above.

Additional information

This is a known behavior in Cobra: https://github.com/spf13/cobra/issues/706 the fix is to add a Cobra.NoArg to every subcommand with child commands.

JIRA Link: CORE-3065

r-vasquez avatar May 22 '24 14:05 r-vasquez