wavetermdev/waveterm · error

getting variable: %w

Error message

getting variable: %w

What it means

This wraps any failure of the GetVarCommand RPC with a 2000ms timeout (cmd/wshcmd-getvar.go:94). The underlying error is usually an RPC transport problem — no connection to the Wave Terminal block/client, timed-out request, or server-side failure resolving the variable zone — not 'key not found' (a missing key returns Exists=false with exit code 1, not this error).

Source

Thrown at cmd/wsh/cmd/wshcmd-getvar.go:94

		return getAllVariables(fullORef.OID)
	}

	// Single variable case - existing logic
	if len(args) != 1 {
		OutputHelpMessage(cmd)
		return fmt.Errorf("requires a key argument")
	}

	key := args[0]
	commandData := wshrpc.CommandVarData{
		Key:      key,
		ZoneId:   fullORef.OID,
		FileName: getVarFileName,
	}

	resp, err := wshclient.GetVarCommand(RpcClient, commandData, &wshrpc.RpcOpts{Timeout: 2000})
	if err != nil {
		return fmt.Errorf("getting variable: %w", err)
	}

	if !resp.Exists {
		WshExitCode = 1
		return nil
	}

	WriteStdout("%s", resp.Val)
	if shouldPrintNewline() {
		WriteStdout("\n")
	}

	return nil
}

func getAllVariables(zoneId string) error {
	commandData := wshrpc.CommandVarData{
		ZoneId:   zoneId,

View on GitHub (pinned to a4447c1563)

Solutions

  1. Verify the Wave app / target block is running and reachable, then retry `wsh getvar KEY`
  2. Use `wsh getvar --local KEY` or a valid --block target to ensure the zone resolves correctly
  3. Check the underlying wrapped error (rpc timeout vs connection refused) and address transport accordingly; increase timeout only if the server is slow

Example fix

// before
wsh getvar FOO   # fails: connection down
// after
wsh conn show    # confirm connection state
wsh getvar FOO   # retry once reachable
Defensive patterns

Strategy: try-catch

Validate before calling

wsh conn show || { echo 'no connection to Wave app'; exit 1; }

Try / catch

if ! out=$(wsh getvar FOO 2>err.txt); then
  if grep -qi 'timeout\|connection' err.txt; then
    echo 'RPC transport failed; check the Wave app is running';
  fi
  exit 1
fi

Prevention

When it happens

Trigger: Calling `wsh getvar KEY` when the wsh RPC client cannot reach the target (Wave app not running, block closed between resolve and call, connection to remote dropped, or the 2s timeout elapses).

Common situations: Running wsh from a remote/ssh session whose connection to the Wave client is down; targeting a block that just closed; slow/saturated connection exceeding the 2s RPC timeout.

Related errors


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