{"record":{"id":"ee496dde45166abf","repo":"wavetermdev/waveterm","slug":"invalid-mode-q-expected-q-or-q","errorCode":null,"errorMessage":"invalid mode %q (expected %q or %q)","messagePattern":"invalid mode %q \\(expected %q or %q\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/wsh/cmd/wshcmd-debugterm.go","lineNumber":129,"sourceCode":"\t\toutput = formatDebugTermDecode(termData)\n\t} else {\n\t\toutput = formatDebugTermHex(termData)\n\t}\n\tWriteStdout(\"%s\", output)\n\treturn nil\n}\n\nfunc debugTermPreRun(cmd *cobra.Command, args []string) error {\n\tif debugTermStdin || debugTermInput != \"\" {\n\t\treturn nil\n\t}\n\treturn preRunSetupRpcClient(cmd, args)\n}\n\nfunc getDebugTermMode() (string, error) {\n\tmode := strings.ToLower(debugTermMode)\n\tif mode != DebugTermModeHex && mode != DebugTermModeDecode {\n\t\treturn \"\", fmt.Errorf(\"invalid mode %q (expected %q or %q)\", debugTermMode, DebugTermModeHex, DebugTermModeDecode)\n\t}\n\treturn mode, nil\n}\n\ntype debugTermStdinEntry struct {\n\tData string `json:\"data\"`\n}\n\nfunc parseDebugTermStdinData(data []byte) ([]byte, error) {\n\ttrimmed := strings.TrimSpace(string(data))\n\tif len(trimmed) == 0 {\n\t\treturn data, nil\n\t}\n\tif trimmed[0] == '[' {\n\t\t// try array of structs first\n\t\tvar structArr []debugTermStdinEntry\n\t\terr := json.Unmarshal(data, &structArr)\n\t\tif err == nil {","sourceCodeStart":111,"sourceCodeEnd":147,"githubUrl":"https://github.com/wavetermdev/waveterm/blob/a4447c1563b2df285ab89e76c82f91e1a1a49c1e/cmd/wsh/cmd/wshcmd-debugterm.go#L111-L147","documentation":"wsh debugterm validates the --mode flag by lowercasing it and comparing against the two allowed modes (hex and decode). If any other value is supplied, getDebugTermMode returns this error and the debugterm command aborts before setting up the RPC client connection.","triggerScenarios":"Running `wsh debugterm --mode <anything-other-than-hex-or-decode>`, including misspellings like 'hexdump', 'Hex ' with whitespace, or 'raw'.","commonSituations":"Guessing at mode names instead of checking `wsh debugterm --help`; scripting the command with a variable that holds an unsupported mode; copy-pasting flags from other wsh subcommands.","solutions":["Run `wsh debugterm --help` to see allowed modes","Pass exactly `hex` or `decode` (case-insensitive) to --mode","Fix the value in your script/alias that supplies the mode"],"exampleFix":"// before\nwsh debugterm --mode hexdump\n// after\nwsh debugterm --mode hex","handlingStrategy":"validation","validationCode":"mode := strings.ToLower(os.Args[len(os.Args)-1]) // value you plan to pass\nif mode != \"hex\" && mode != \"decode\" {\n    return fmt.Errorf(\"unsupported debugterm mode %q; use hex or decode\", mode)\n}","typeGuard":"func isValidDebugTermMode(s string) bool {\n    switch strings.ToLower(s) {\n    case \"hex\", \"decode\":\n        return true\n    }\n    return false\n}","tryCatchPattern":null,"preventionTips":["Always pass --mode hex or --mode decode explicitly","Check `wsh debugterm --help` before scripting","Normalize case in scripts before invoking"],"tags":["cli","validation","argument-error"],"backgroundTag":"invalid-flag-value","analyzedSha":"a4447c1563b2df285ab89e76c82f91e1a1a49c1e","analyzedAt":"2026-09-01T15:26:23.972Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}