{"record":{"id":"c5f44ea1e4e41309","repo":"caddyserver/caddy","slug":"unrecognized-shell-s","errorCode":null,"errorMessage":"unrecognized shell: %s","messagePattern":"unrecognized shell: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/commands.go","lineNumber":545,"sourceCode":"\t  PS> %[1]s completion powershell > %[1]s.ps1\n\t  # and source this file from your PowerShell profile.\n\t`, rootCmd.Root().Name()),\n\t\t\tCobraFunc: func(cmd *cobra.Command) {\n\t\t\t\tcmd.DisableFlagsInUseLine = true\n\t\t\t\tcmd.ValidArgs = []string{\"bash\", \"zsh\", \"fish\", \"powershell\"}\n\t\t\t\tcmd.Args = cobra.MatchAll(cobra.ExactArgs(1), cobra.OnlyValidArgs)\n\t\t\t\tcmd.RunE = func(cmd *cobra.Command, args []string) error {\n\t\t\t\t\tswitch args[0] {\n\t\t\t\t\tcase \"bash\":\n\t\t\t\t\t\treturn cmd.Root().GenBashCompletion(os.Stdout)\n\t\t\t\t\tcase \"zsh\":\n\t\t\t\t\t\treturn cmd.Root().GenZshCompletion(os.Stdout)\n\t\t\t\t\tcase \"fish\":\n\t\t\t\t\t\treturn cmd.Root().GenFishCompletion(os.Stdout, true)\n\t\t\t\t\tcase \"powershell\":\n\t\t\t\t\t\treturn cmd.Root().GenPowerShellCompletionWithDesc(os.Stdout)\n\t\t\t\t\tdefault:\n\t\t\t\t\t\treturn fmt.Errorf(\"unrecognized shell: %s\", args[0])\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t},\n\t\t}\n\n\t\trootCmd.AddCommand(caddyCmdToCobra(manpageCommand))\n\t\trootCmd.AddCommand(caddyCmdToCobra(completionCommand))\n\n\t\t// add manpage and completion commands to the map of\n\t\t// available commands, because they're not registered\n\t\t// through RegisterCommand.\n\t\tcommandsMu.Lock()\n\t\tcommands[manpageCommand.Name] = manpageCommand\n\t\tcommands[completionCommand.Name] = completionCommand\n\t\tcommandsMu.Unlock()\n\t})\n}\n","sourceCodeStart":527,"sourceCodeEnd":563,"githubUrl":"https://github.com/caddyserver/caddy/blob/50e54ee279aa1e504fe218ca49ab6ae16c100410/cmd/commands.go#L527-L563","documentation":"The 'completion' command's switch over the single shell argument fell through to default. Bash, zsh, fish, and powershell are the supported shells; anything else reaches this error. Note cobra's OnlyValidArgs normally intercepts invalid values first, so hitting this message means validation was bypassed (custom build, older cobra, or direct invocation of the RunE).","triggerScenarios":"Running 'caddy completion tcsh' or 'caddy completion sh'; a typo like 'caddy completion bahs'.","commonSituations":"Users expecting a generic POSIX completion output; scripts hardcoding a shell name not in the supported set.","solutions":["Use one of: bash, zsh, fish, powershell","Check caddy completion --help for the exact accepted values"],"exampleFix":"# before\ncaddy completion sh\n\n# after\ncaddy completion bash","handlingStrategy":"validation","validationCode":"shell := args[0]\nvalid := map[string]bool{\"bash\": true, \"zsh\": true, \"fish\": true, \"powershell\": true}\nif !valid[shell] { return fmt.Errorf(\"unsupported shell %q; use bash|zsh|fish|powershell\", shell) }","typeGuard":"func isValidShell(s string) bool { switch s { case \"bash\", \"zsh\", \"fish\", \"powershell\": return true }; return false }","tryCatchPattern":null,"preventionTips":["Whitelist shell names at the call site","Read 'caddy completion --help' for accepted values before scripting"],"tags":["cli","shell-completion","invalid-argument"],"backgroundTag":null,"analyzedSha":"50e54ee279aa1e504fe218ca49ab6ae16c100410","analyzedAt":"2026-08-15T09:20:21.641Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}