{"record":{"id":"d4a1ea9dc267eb46","repo":"wavetermdev/waveterm","slug":"cannot-determine-blockid-not-in-jwt-d4a1ea","errorCode":null,"errorMessage":"cannot determine blockid (not in JWT)","messagePattern":"cannot determine blockid \\(not in JWT\\)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/wsh/cmd/wshcmd-wsl.go","lineNumber":49,"sourceCode":"func wslRun(cmd *cobra.Command, args []string) (rtnErr error) {\n\tdefer func() {\n\t\tsendActivity(\"wsl\", rtnErr == nil)\n\t}()\n\n\tvar err error\n\tif distroName == \"\" {\n\t\t// get default distro from the host\n\t\tdistroName, err = wshclient.WslDefaultDistroCommand(RpcClient, nil)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\tif !strings.HasPrefix(distroName, \"wsl://\") {\n\t\tdistroName = \"wsl://\" + distroName\n\t}\n\tblockId := RpcContext.BlockId\n\tif blockId == \"\" {\n\t\treturn fmt.Errorf(\"cannot determine blockid (not in JWT)\")\n\t}\n\tdata := wshrpc.CommandSetMetaData{\n\t\tORef: waveobj.MakeORef(waveobj.OType_Block, blockId),\n\t\tMeta: map[string]any{\n\t\t\twaveobj.MetaKey_Connection: distroName,\n\t\t},\n\t}\n\terr = wshclient.SetMetaCommand(RpcClient, data, nil)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"setting connection in block: %w\", err)\n\t}\n\tWriteStderr(\"switched connection to %q\\n\", distroName)\n\treturn nil\n}\n","sourceCodeStart":31,"sourceCodeEnd":64,"githubUrl":"https://github.com/wavetermdev/waveterm/blob/a4447c1563b2df285ab89e76c82f91e1a1a49c1e/cmd/wsh/cmd/wshcmd-wsl.go#L31-L64","documentation":"wslRun sets the current block's connection meta to a WSL distro. It reads the block id from the authenticated RPC context (RpcContext.BlockId, embedded in the wsh JWT). If the JWT carries no block id — e.g. wsh invoked outside a block context — it cannot know which block to update and errors with this message.","triggerScenarios":"Running `wsh wsl set <distro>` (or similar) from a shell whose WAVETERM JWT lacks the BlockId claim: launched from outside a Wave terminal block, or an env/JWT generated without block context.","commonSituations":"Using wsh in a detached terminal or IDE shell; stale/reissued JWT without block scope; running wsh as another user so the JWT env var is missing.","solutions":["Run the command inside a Wave Terminal block so the JWT includes BlockId","Restart the Wave terminal/tab to regenerate a proper JWT","Set the connection globally instead of per-block (wave connection settings) if block context is not available"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"if RpcContext.BlockId == \"\" {\n    return errors.New(\"wsh must run inside a Wave Terminal block (BlockId missing from JWT)\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Invoke wsh wsl commands from within a Wave Terminal block","Do not clear WAVETERM_* env vars in shells or wrappers","Regenerate context (restart tab) if the JWT predates block creation"],"tags":["cli","jwt","wave-terminal"],"backgroundTag":"missing-blockid-in-jwt","analyzedSha":"a4447c1563b2df285ab89e76c82f91e1a1a49c1e","analyzedAt":"2026-09-01T15:26:23.972Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}