wavetermdev/waveterm · error

cannot determine blockid (not in JWT)

Error message

cannot determine blockid (not in JWT)

What it means

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.

Source

Thrown at cmd/wsh/cmd/wshcmd-wsl.go:49

func wslRun(cmd *cobra.Command, args []string) (rtnErr error) {
	defer func() {
		sendActivity("wsl", rtnErr == nil)
	}()

	var err error
	if distroName == "" {
		// get default distro from the host
		distroName, err = wshclient.WslDefaultDistroCommand(RpcClient, nil)
		if err != nil {
			return err
		}
	}
	if !strings.HasPrefix(distroName, "wsl://") {
		distroName = "wsl://" + distroName
	}
	blockId := RpcContext.BlockId
	if blockId == "" {
		return fmt.Errorf("cannot determine blockid (not in JWT)")
	}
	data := wshrpc.CommandSetMetaData{
		ORef: waveobj.MakeORef(waveobj.OType_Block, blockId),
		Meta: map[string]any{
			waveobj.MetaKey_Connection: distroName,
		},
	}
	err = wshclient.SetMetaCommand(RpcClient, data, nil)
	if err != nil {
		return fmt.Errorf("setting connection in block: %w", err)
	}
	WriteStderr("switched connection to %q\n", distroName)
	return nil
}

View on GitHub (pinned to a4447c1563)

Solutions

  1. Run the command inside a Wave Terminal block so the JWT includes BlockId
  2. Restart the Wave terminal/tab to regenerate a proper JWT
  3. Set the connection globally instead of per-block (wave connection settings) if block context is not available
Defensive patterns

Strategy: validation

Validate before calling

if RpcContext.BlockId == "" {
    return errors.New("wsh must run inside a Wave Terminal block (BlockId missing from JWT)")
}

Prevention

When it happens

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

Common situations: 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.

Related errors


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