cilium/cilium · error

invalid arguments: get requires exactly 0 or 1 argument: got

Error message

invalid arguments: get requires exactly 0 or 1 argument: got '%s'

What it means

The hubble CLI 'config get' command accepts at most one argument (the config key to read). RunGet dispatches on len(args): 0 args shows the current config view, 1 arg fetches the key, and anything more returns this error. It is a usage/arity guard thrown by the command's Args/E handler in cmd/config/get.go.

Source

Thrown at hubble/cmd/config/get.go:29

	"github.com/spf13/viper"
	"go.yaml.in/yaml/v3"
)

func newGetCommand(vp *viper.Viper) *cobra.Command {
	return &cobra.Command{
		Use:   "get [KEY]",
		Short: "Get an individual value in the hubble config file",
		Long: "Get an individual value in the hubble config file.\n" +
			"If KEY is not provided, this command is equivalent to 'view'.",
		ValidArgs: vp.AllKeys(),
		RunE: func(cmd *cobra.Command, args []string) error {
			switch len(args) {
			case 1:
				return runGet(cmd, vp, args[0])
			case 0:
				return runView(cmd, vp)
			default:
				return fmt.Errorf("invalid arguments: get requires exactly 0 or 1 argument: got '%s'", strings.Join(args, " "))
			}
		},
	}
}

func runGet(cmd *cobra.Command, vp *viper.Viper, key string) error {
	if !isKey(vp, key) {
		return fmt.Errorf("unknown key: %s", key)
	}

	// each viper key/val entry should be bound to a command flag
	flag := cmd.Flag(key)
	if flag == nil {
		return fmt.Errorf("key=%s not bound to a flag", key)
	}

	var val any
	switch typ := flag.Value.Type(); typ {

View on GitHub (pinned to ac7b90affa)

Solutions

  1. Call 'hubble config get' with at most one key: 'hubble config get <key>'
  2. If you need multiple keys, run the command once per key or use 'hubble config' (view) to see all values
  3. Check shell quoting: wrap variables in double quotes, e.g. "hubble config get $KEY"
  4. Run 'hubble config get --help' to confirm accepted argument counts

Example fix

// before
hubble config get server-rate-limit flow-rate-limit
// after
hubble config get server-rate-limit
hubble config get flow-rate-limit
Defensive patterns

Strategy: validation

Validate before calling

// Validate arg count before invoking
args="$*"
count=$(echo $args | wc -w)
if [ "$count" -gt 1 ]; then
  echo "config get accepts at most 1 key; got $count"
  exit 1
fi
hubble config get "$1"

Try / catch

// Bash: check exit code of hubble (cobra returns the error's message and code 1)
if ! out=$(hubble config get "$key" 2>&1); then
  case "$out" in
    *"invalid arguments: get requires"*) echo "Usage: hubble config get [key]" ;;
    *) echo "$out" ;;
  esac
fi

Prevention

When it happens

Trigger: Running 'hubble config get key1 key2' (two or more positional args), e.g. pasting a multi-word key, quoting mistakes, or scripting that expands extra tokens.

Common situations: Scripts passing unquoted variables that split into multiple words; users copying CLI examples for other tools; shell glob expansion adding arguments.

Related errors


AI-assisted analysis of cilium/cilium@ac7b90affa (2026-08-31). Data as JSON: /api/errors/8659de6f1b4c5176. Report an issue: GitHub.