{"record":{"id":"8659de6f1b4c5176","repo":"cilium/cilium","slug":"invalid-arguments-get-requires-exactly-0-or-1-arg","errorCode":null,"errorMessage":"invalid arguments: get requires exactly 0 or 1 argument: got '%s'","messagePattern":"invalid arguments: get requires exactly 0 or 1 argument: got '(.+?)'","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"hubble/cmd/config/get.go","lineNumber":29,"sourceCode":"\t\"github.com/spf13/viper\"\n\t\"go.yaml.in/yaml/v3\"\n)\n\nfunc newGetCommand(vp *viper.Viper) *cobra.Command {\n\treturn &cobra.Command{\n\t\tUse:   \"get [KEY]\",\n\t\tShort: \"Get an individual value in the hubble config file\",\n\t\tLong: \"Get an individual value in the hubble config file.\\n\" +\n\t\t\t\"If KEY is not provided, this command is equivalent to 'view'.\",\n\t\tValidArgs: vp.AllKeys(),\n\t\tRunE: func(cmd *cobra.Command, args []string) error {\n\t\t\tswitch len(args) {\n\t\t\tcase 1:\n\t\t\t\treturn runGet(cmd, vp, args[0])\n\t\t\tcase 0:\n\t\t\t\treturn runView(cmd, vp)\n\t\t\tdefault:\n\t\t\t\treturn fmt.Errorf(\"invalid arguments: get requires exactly 0 or 1 argument: got '%s'\", strings.Join(args, \" \"))\n\t\t\t}\n\t\t},\n\t}\n}\n\nfunc runGet(cmd *cobra.Command, vp *viper.Viper, key string) error {\n\tif !isKey(vp, key) {\n\t\treturn fmt.Errorf(\"unknown key: %s\", key)\n\t}\n\n\t// each viper key/val entry should be bound to a command flag\n\tflag := cmd.Flag(key)\n\tif flag == nil {\n\t\treturn fmt.Errorf(\"key=%s not bound to a flag\", key)\n\t}\n\n\tvar val any\n\tswitch typ := flag.Value.Type(); typ {","sourceCodeStart":11,"sourceCodeEnd":47,"githubUrl":"https://github.com/cilium/cilium/blob/ac7b90affa4baf0642e6685319d56907b3a73a6d/hubble/cmd/config/get.go#L11-L47","documentation":"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.","triggerScenarios":"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.","commonSituations":"Scripts passing unquoted variables that split into multiple words; users copying CLI examples for other tools; shell glob expansion adding arguments.","solutions":["Call 'hubble config get' with at most one key: 'hubble config get <key>'","If you need multiple keys, run the command once per key or use 'hubble config' (view) to see all values","Check shell quoting: wrap variables in double quotes, e.g. \"hubble config get $KEY\"","Run 'hubble config get --help' to confirm accepted argument counts"],"exampleFix":"// before\nhubble config get server-rate-limit flow-rate-limit\n// after\nhubble config get server-rate-limit\nhubble config get flow-rate-limit","handlingStrategy":"validation","validationCode":"// Validate arg count before invoking\nargs=\"$*\"\ncount=$(echo $args | wc -w)\nif [ \"$count\" -gt 1 ]; then\n  echo \"config get accepts at most 1 key; got $count\"\n  exit 1\nfi\nhubble config get \"$1\"","typeGuard":null,"tryCatchPattern":"// Bash: check exit code of hubble (cobra returns the error's message and code 1)\nif ! out=$(hubble config get \"$key\" 2>&1); then\n  case \"$out\" in\n    *\"invalid arguments: get requires\"*) echo \"Usage: hubble config get [key]\" ;;\n    *) echo \"$out\" ;;\n  esac\nfi","preventionTips":["Always pass exactly one quoted key to 'config get'","Quote shell variables to avoid word splitting","Use 'hubble config' (view) when you want all values instead of multiple get calls"],"tags":["cli","cobra","argument-validation"],"backgroundTag":"invalid-cli-arguments","analyzedSha":"ac7b90affa4baf0642e6685319d56907b3a73a6d","analyzedAt":"2026-08-31T18:27:15.868Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}