wavetermdev/waveterm · error

wsh token requires non-empty arguments

Error message

wsh token requires non-empty arguments

What it means

Returned by wsh token when no subcommand/arguments are supplied; token requires an action such as gen or build.

Source

Thrown at cmd/wsh/cmd/wshcmd-token.go:32

	Use:    "token [token] [shell-type]",
	Short:  "exchange token for shell initialization script",
	RunE:   tokenCmdRun,
	Hidden: true,
}

func init() {
	rootCmd.AddCommand(tokenCmd)
}

func tokenCmdRun(cmd *cobra.Command, args []string) (rtnErr error) {
	if len(args) != 2 {
		OutputHelpMessage(cmd)
		return fmt.Errorf("wsh token requires exactly 2 arguments, got %d", len(args))
	}
	tokenStr, shellType := args[0], args[1]
	if tokenStr == "" || shellType == "" {
		OutputHelpMessage(cmd)
		return fmt.Errorf("wsh token requires non-empty arguments")
	}
	rtnData, err := setupRpcClientWithToken(tokenStr)
	if err != nil {
		return fmt.Errorf("error setting up rpc client: %w", err)
	}
	envScriptText, err := shellutil.EncodeEnvVarsForShell(shellType, rtnData.Env)
	if err != nil {
		return fmt.Errorf("error encoding env vars: %w", err)
	}
	WriteStdout("%s\n", envScriptText)
	WriteStdout("%s\n", rtnData.InitScriptText)
	return nil
}

View on GitHub (pinned to a4447c1563)

Solutions

  1. Pass a real token string obtained from the Wave app (Run: `wsh token` inside Wave prints usage; copy the full token).
  2. Pass a valid shell type (bash, zsh, powershell, cmd) instead of an empty string.
  3. In scripts, guard against empty variables: `[ -n "$TOKEN" ] || exit 1`.

Example fix

// before
wsh token "$TOKEN" "$SHELLTYPE"
// after
if [ -z "$TOKEN" ] || [ -z "$SHELLTYPE" ]; then echo "token and shell type required"; exit 1; fi
wsh token "$TOKEN" "$SHELLTYPE"
Defensive patterns

Strategy: validation

Validate before calling

# guard against empty/unset variables before invoking
[ -n "$TOKEN" ] && [ -n "$SHELLTYPE" ] || { echo "token and shelltype must be non-empty"; exit 1; }
wsh token "$TOKEN" "$SHELLTYPE"

Try / catch

if [ -z "$TOKEN" ]; then echo "TOKEN is empty — was it exported?" >&2; exit 1; fi
wsh token "$TOKEN" "$SHELLTYPE" || { echo "wsh token failed" >&2; exit 1; }

Prevention

When it happens

Trigger: `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.

Common situations: Shell variable empty due to unset env var; copying a token with only whitespace stripped; script passing an unbound parameter.

Related errors


AI-assisted analysis of wavetermdev/waveterm@a4447c1563 (2026-09-01). Data as JSON: /api/errors/51fb024804d56f85. Report an issue: GitHub.