{"record":{"id":"95ad4cee8ea79e5d","repo":"wavetermdev/waveterm","slug":"error-setting-up-rpc-client-w","errorCode":null,"errorMessage":"error setting up rpc client: %w","messagePattern":"error setting up rpc client: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/wsh/cmd/wshcmd-token.go","lineNumber":36,"sourceCode":"}\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":18,"sourceCodeEnd":46,"githubUrl":"https://github.com/wavetermdev/waveterm/blob/a4447c1563b2df285ab89e76c82f91e1a1a49c1e/cmd/wsh/cmd/wshcmd-token.go#L18-L46","documentation":"tokenCmdRun calls setupRpcClientWithToken to build an RPC client authenticated with the provided token. If that setup fails — invalid token, no running Wave app to connect to, connection/route errors — the cause is wrapped as 'error setting up rpc client'.","triggerScenarios":"setupRpcClientWithToken returning an error: token rejected/expired, no Wave app listening, network or route resolution failure during client handshake.","commonSituations":"Copy-pasting a stale token from an old session; running the command on a machine where Wave isn't running; token rotated after Wave restart.","solutions":["Regenerate the token from the Wave app (it rotates per session) and retry.","Confirm the Wave app is running and reachable from this shell.","Inspect the wrapped %w error to distinguish auth rejection from connection failure."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"# confirm connectivity before the token command\ncurl -sf http://localhost:${WAVE_PORT:-$(default_wave_port)} >/dev/null || echo \"Wave app not reachable\"","typeGuard":null,"tryCatchPattern":"rtnData, err := setupRpcClientWithToken(tokenStr)\nif err != nil {\n\tif errors.Is(err, context.DeadlineExceeded) {\n\t\t// app not responding: retry after restarting Wave\n\t}\n\t// invalid token: fetch a fresh token from the Wave app\n\treturn fmt.Errorf(\"error setting up rpc client: %w\", err)\n}","preventionTips":["Refresh tokens whenever the Wave app restarts (they may rotate).","Ensure the Wave app is running on the same machine/session before authenticating.","Distinguish auth errors from connection errors by inspecting the wrapped cause."],"tags":["rpc","auth","token"],"backgroundTag":"invalid-wsh-token","analyzedSha":"a4447c1563b2df285ab89e76c82f91e1a1a49c1e","analyzedAt":"2026-09-01T15:26:23.972Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}