{"record":{"id":"066db8afb429589b","repo":"wavetermdev/waveterm","slug":"creating-new-terminal-block-w-066db8","errorCode":null,"errorMessage":"creating new terminal block: %w","messagePattern":"creating new terminal block: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/wsh/cmd/wshcmd-term.go","lineNumber":82,"sourceCode":"\tcreateMeta := map[string]any{\n\t\twaveobj.MetaKey_View:       \"term\",\n\t\twaveobj.MetaKey_CmdCwd:     cwd,\n\t\twaveobj.MetaKey_Controller: \"shell\",\n\t}\n\tif RpcContext.Conn != \"\" {\n\t\tcreateMeta[waveobj.MetaKey_Connection] = RpcContext.Conn\n\t}\n\tcreateBlockData := wshrpc.CommandCreateBlockData{\n\t\tTabId: tabId,\n\t\tBlockDef: &waveobj.BlockDef{\n\t\t\tMeta: createMeta,\n\t\t},\n\t\tMagnified: termMagnified,\n\t\tFocused:   true,\n\t}\n\toref, err := wshclient.CreateBlockCommand(RpcClient, createBlockData, nil)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"creating new terminal block: %w\", err)\n\t}\n\tWriteStdout(\"terminal block created: %s\\n\", oref)\n\treturn nil\n}\n","sourceCodeStart":64,"sourceCodeEnd":87,"githubUrl":"https://github.com/wavetermdev/waveterm/blob/a4447c1563b2df285ab89e76c82f91e1a1a49c1e/cmd/wsh/cmd/wshcmd-term.go#L64-L87","documentation":"wsh term creates a new terminal block in the Wave UI via the CreateBlockCommand RPC. When the RPC fails — typically because no Wave app is running to answer it, the connection/route is bad, or the server rejects the block-creation request — the CLI wraps the underlying error with this message.","triggerScenarios":"Running `wsh term` (or `wsh term --magnified`) when CreateBlockCommand returns an error: no Wave app running, RPC connection failure, or server-side rejection of the create-block request.","commonSituations":"Invoking `wsh term` from a plain shell without a Wave terminal host available; a stale or mismatched wsh token; Wave app restarting while wsh connects.","solutions":["Start the Wave Terminal app so an RPC server is available, then retry `wsh term`.","Check wsh connectivity/token setup (e.g. `wsh token` / wsheditordata) and re-run.","Inspect the wrapped %w error for the root cause (timeout vs. connection refused vs. server rejection)."],"exampleFix":"// before\noref, err := wshclient.CreateBlockCommand(RpcClient, createBlockData, nil)\nif err != nil {\n\treturn fmt.Errorf(\"creating new terminal block: %w\", err)\n}\n// after\nif RpcClient == nil {\n\treturn fmt.Errorf(\"no wsh RPC connection: run this inside a Wave terminal\")\n}\noref, err := wshclient.CreateBlockCommand(RpcClient, createBlockData, nil)\nif err != nil {\n\treturn fmt.Errorf(\"creating new terminal block: %w\", err)\n}","handlingStrategy":"try-catch","validationCode":"// before calling wsh term, confirm a Wave app is reachable\nif !isWaveAppRunning() {\n\tfmt.Fprintln(os.Stderr, \"Wave Terminal is not running; start it before `wsh term`\")\n\tos.Exit(1)\n}","typeGuard":"func hasRpcClient(c *wshrpc.RpcClient) bool { return c != nil }","tryCatchPattern":"oref, err := wshclient.CreateBlockCommand(RpcClient, createBlockData, nil)\nif err != nil {\n\tif errors.Is(err, context.DeadlineExceeded) {\n\t\t// timeout: app hung or absent\n\t} else {\n\t\t// connection or rejection: check app running / token\n\t}\n\treturn fmt.Errorf(\"creating new terminal block: %w\", err)\n}","preventionTips":["Run wsh commands only from inside a Wave terminal or with a running Wave app.","Keep wsh tokens in sync after Wave restarts.","Log the wrapped root error (%w) rather than just the wrapper message."],"tags":["rpc","cli","terminal"],"backgroundTag":"rpc-call-failed","analyzedSha":"a4447c1563b2df285ab89e76c82f91e1a1a49c1e","analyzedAt":"2026-09-01T15:26:23.972Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}