{"record":{"id":"4f6d3fd8fb2d3257","repo":"cilium/cilium","slug":"too-many-arguments-expected-only-the-shell-type-4f6d3f","errorCode":null,"errorMessage":"too many arguments; expected only the shell type: %s","messagePattern":"too many arguments; expected only the shell type: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"hubble-relay/cmd/completion/completion.go","lineNumber":29,"sourceCode":")\n\n// New creates a new shell completion command.\nfunc New() *cobra.Command {\n\treturn &cobra.Command{\n\t\tUse:     \"completion [shell]\",\n\t\tShort:   \"Output shell completion code\",\n\t\tLong:    \"Output shell completion code for bash and zsh\",\n\t\tExample: completionExample,\n\t\tRunE: func(cmd *cobra.Command, args []string) error {\n\t\t\treturn runCompletion(cmd.OutOrStdout(), cmd, args)\n\t\t},\n\t\tValidArgs: []string{\"bash\", \"zsh\"},\n\t}\n}\n\nfunc runCompletion(out io.Writer, cmd *cobra.Command, args []string) error {\n\tif len(args) > 1 {\n\t\treturn fmt.Errorf(\"too many arguments; expected only the shell type: %s\", args)\n\t}\n\n\tif len(args) == 0 || args[0] == \"bash\" {\n\t\treturn cmd.Root().GenBashCompletion(out)\n\t}\n\tif args[0] == \"zsh\" {\n\t\treturn cmd.Root().GenZshCompletion(out)\n\t}\n\treturn fmt.Errorf(\"unsupported shell: %s\", args[0])\n}\n\nconst completionExample = `\n# Installing bash completion on macOS using homebrew\n## If running Bash 3.2 included with macOS\n\tbrew install bash-completion\n## or, if running Bash 4.1+\n\tbrew install bash-completion@2\n## afterwards you only need to run","sourceCodeStart":11,"sourceCodeEnd":47,"githubUrl":"https://github.com/cilium/cilium/blob/ac7b90affa4baf0642e6685319d56907b3a73a6d/hubble-relay/cmd/completion/completion.go#L11-L47","documentation":"The `hubble-relay completion` command accepts at most one argument (the shell name: bash or zsh). runCompletion returns this error when more than one positional argument is supplied. The extra arguments are echoed back in the message.","triggerScenarios":"Running `hubble-relay completion bash zsh`, `completion zsh extra`, or any invocation with two or more positional arguments after the completion subcommand.","commonSituations":"Typo or copy-paste of shell names together ('completion bash zsh'), scripted installation lines accidentally appending extra words, or assuming the command takes flags for shell selection.","solutions":["Pass exactly one shell argument: `hubble-relay completion bash` or `hubble-relay completion zsh`.","Check your install script for stray/unquoted variable expansions producing extra words.","Run `hubble-relay completion --help` to see the accepted arguments."],"exampleFix":"// before\nhubble-relay completion bash zsh > /dev/null\n// after\nhubble-relay completion bash > /etc/bash_completion.d/hubble-relay","handlingStrategy":"validation","validationCode":"// Validate CLI args before invoking\nshells := []string{\"bash\", \"zsh\"}\nif len(args) != 1 || !slices.Contains(shells, args[0]) {\n    return fmt.Errorf(\"usage: hubble-relay completion [bash|zsh]\")\n}","typeGuard":null,"tryCatchPattern":"out, err := exec.Command(\"hubble-relay\", \"completion\", shell).CombinedOutput()\nif err != nil && strings.Contains(err.Error(), \"too many arguments\") {\n    log.Fatalf(\"install script bug: pass exactly one shell: %v\", err)\n}","preventionTips":["Quote shell variables in install scripts to avoid word-splitting extras","Document the exact completion invocation in your setup tooling","Check `hubble-relay completion --help` before scripting"],"tags":["cli","arguments","completion"],"backgroundTag":"invalid-cli-arguments","analyzedSha":"ac7b90affa4baf0642e6685319d56907b3a73a6d","analyzedAt":"2026-08-31T18:27:15.868Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}