{"record":{"id":"51fb024804d56f85","repo":"wavetermdev/waveterm","slug":"wsh-token-requires-non-empty-arguments","errorCode":null,"errorMessage":"wsh token requires non-empty arguments","messagePattern":"wsh token requires non-empty arguments","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/wsh/cmd/wshcmd-token.go","lineNumber":32,"sourceCode":"\tUse:    \"token [token] [shell-type]\",\n\tShort:  \"exchange token for shell initialization script\",\n\tRunE:   tokenCmdRun,\n\tHidden: true,\n}\n\nfunc init() {\n\trootCmd.AddCommand(tokenCmd)\n}\n\nfunc tokenCmdRun(cmd *cobra.Command, args []string) (rtnErr error) {\n\tif len(args) != 2 {\n\t\tOutputHelpMessage(cmd)\n\t\treturn fmt.Errorf(\"wsh token requires exactly 2 arguments, got %d\", len(args))\n\t}\n\ttokenStr, shellType := args[0], args[1]\n\tif tokenStr == \"\" || shellType == \"\" {\n\t\tOutputHelpMessage(cmd)\n\t\treturn fmt.Errorf(\"wsh token requires non-empty arguments\")\n\t}\n\trtnData, err := setupRpcClientWithToken(tokenStr)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"error setting up rpc client: %w\", err)\n\t}\n\tenvScriptText, err := shellutil.EncodeEnvVarsForShell(shellType, rtnData.Env)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"error encoding env vars: %w\", err)\n\t}\n\tWriteStdout(\"%s\\n\", envScriptText)\n\tWriteStdout(\"%s\\n\", rtnData.InitScriptText)\n\treturn nil\n}\n","sourceCodeStart":14,"sourceCodeEnd":46,"githubUrl":"https://github.com/wavetermdev/waveterm/blob/a4447c1563b2df285ab89e76c82f91e1a1a49c1e/cmd/wsh/cmd/wshcmd-token.go#L14-L46","documentation":"Returned by wsh token when no subcommand/arguments are supplied; token requires an action such as gen or build.","triggerScenarios":"`wsh token \"\" bash` or `wsh token mytoken \"\"` — an empty token or empty shellType from variable interpolation like `wsh token \"$TOKEN\" bash` where TOKEN is unset.","commonSituations":"Shell variable empty due to unset env var; copying a token with only whitespace stripped; script passing an unbound parameter.","solutions":["Pass a real token string obtained from the Wave app (Run: `wsh token` inside Wave prints usage; copy the full token).","Pass a valid shell type (bash, zsh, powershell, cmd) instead of an empty string.","In scripts, guard against empty variables: `[ -n \"$TOKEN\" ] || exit 1`."],"exampleFix":"// before\nwsh token \"$TOKEN\" \"$SHELLTYPE\"\n// after\nif [ -z \"$TOKEN\" ] || [ -z \"$SHELLTYPE\" ]; then echo \"token and shell type required\"; exit 1; fi\nwsh token \"$TOKEN\" \"$SHELLTYPE\"","handlingStrategy":"validation","validationCode":"# guard against empty/unset variables before invoking\n[ -n \"$TOKEN\" ] && [ -n \"$SHELLTYPE\" ] || { echo \"token and shelltype must be non-empty\"; exit 1; }\nwsh token \"$TOKEN\" \"$SHELLTYPE\"","typeGuard":null,"tryCatchPattern":"if [ -z \"$TOKEN\" ]; then echo \"TOKEN is empty — was it exported?\" >&2; exit 1; fi\nwsh token \"$TOKEN\" \"$SHELLTYPE\" || { echo \"wsh token failed\" >&2; exit 1; }","preventionTips":["Never pass \"\" for token or shell type; check variables with ${VAR:?unset}.","Copy the full token including any padding characters.","Use explicit shell names rather than variables that may default to empty."],"tags":["cli","argument-validation"],"backgroundTag":"missing-or-empty-argument","analyzedSha":"a4447c1563b2df285ab89e76c82f91e1a1a49c1e","analyzedAt":"2026-09-01T15:26:23.972Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}