{"record":{"id":"2540d6506be06af4","repo":"wavetermdev/waveterm","slug":"no-waveterm-tabid-env-var-set","errorCode":null,"errorMessage":"no WAVETERM_TABID env var set","messagePattern":"no WAVETERM_TABID env var set","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/wsh/cmd/wshcmd-createblock.go","lineNumber":39,"sourceCode":"\tRunE:    createBlockRun,\n\tPreRunE: preRunSetupRpcClient,\n\tHidden:  true,\n}\n\nfunc init() {\n\tcreateBlockCmd.Flags().BoolVarP(&createBlockMagnified, \"magnified\", \"m\", false, \"create block in magnified mode\")\n\trootCmd.AddCommand(createBlockCmd)\n}\n\nfunc createBlockRun(cmd *cobra.Command, args []string) error {\n\tviewName := args[0]\n\tvar metaSetStrs []string\n\tif len(args) > 1 {\n\t\tmetaSetStrs = args[1:]\n\t}\n\ttabId := getTabIdFromEnv()\n\tif tabId == \"\" {\n\t\treturn fmt.Errorf(\"no WAVETERM_TABID env var set\")\n\t}\n\tmeta, err := parseMetaSets(metaSetStrs)\n\tif err != nil {\n\t\treturn err\n\t}\n\tmeta[\"view\"] = viewName\n\tdata := wshrpc.CommandCreateBlockData{\n\t\tTabId: tabId,\n\t\tBlockDef: &waveobj.BlockDef{\n\t\t\tMeta: meta,\n\t\t},\n\t\tMagnified: createBlockMagnified,\n\t\tFocused:   true,\n\t}\n\toref, err := wshclient.CreateBlockCommand(RpcClient, data, nil)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"create block failed: %v\", err)\n\t}","sourceCodeStart":21,"sourceCodeEnd":57,"githubUrl":"https://github.com/wavetermdev/waveterm/blob/a4447c1563b2df285ab89e76c82f91e1a1a49c1e/cmd/wsh/cmd/wshcmd-createblock.go#L21-L57","documentation":"wsh createblock must know which tab to place the new block in, taken from the WAVETERM_TABID environment variable via getTabIdFromEnv. If the variable is unset or empty, createBlockRun returns this error instead of making an RPC call.","triggerScenarios":"Running `wsh createblock` outside a Wave terminal block (plain SSH session, external terminal, CI shell) where WAVETERM_TABID is not exported.","commonSituations":"Running wsh over a raw ssh connection instead of inside a Wave block; a shell that scrubbed the environment (sudo, env -i, docker exec); running in a new tmux/screen session spawned before entering Wave.","solutions":["Run the command inside a Wave terminal block so WAVETERM_TABID is set","Export WAVETERM_TABID manually if invoking from a script: export WAVETERM_TABID=<tabid>","Avoid env-scrubbing wrappers (sudo -E, env -i, docker exec without -e)","Use the block controller/other RPC entry points when operating outside a tab context"],"exampleFix":"// before\nssh host 'wsh createblock editor'   # no WAVETERM_TABID on remote shell\n// after\n# run inside a Wave block:\nwsh createblock editor\n// or\nexport WAVETERM_TABID=\"$TAB_ID\" && wsh createblock editor","handlingStrategy":"fallback","validationCode":"if [ -z \"$WAVETERM_TABID\" ]; then\n  echo \"WAVETERM_TABID not set — run inside a Wave terminal block\" >&2\n  exit 1\nfi","typeGuard":null,"tryCatchPattern":"out, err := runWsh(\"createblock\", view)\nif err != nil && strings.Contains(out, \"WAVETERM_TABID\") {\n\t// fall back: prompt for or look up the tab id, then retry with env set\n\tcmd.Env = append(os.Environ(), \"WAVETERM_TABID=\"+tabId)\n}","preventionTips":["Only run createblock from inside a Wave terminal block","Don't scrub the environment with sudo/env -i/docker exec without -e","For remote/automation use, export WAVETERM_TABID explicitly before invoking","Check `wsh info`-style output to confirm the block context is present"],"tags":["environment-variable","cli","wave-terminal"],"backgroundTag":"missing-env-var","analyzedSha":"a4447c1563b2df285ab89e76c82f91e1a1a49c1e","analyzedAt":"2026-09-01T15:26:23.972Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}