wavetermdev/waveterm · error

command packets may not have datatype set

Error message

command packets may not have datatype set

What it means

Packet validation error: COMMAND packets must not set a datatype. Datatype describes response payload encoding and is invalid on an outbound command packet, which is rejected.

Source

Thrown at pkg/wshutil/wshrpc.go:169

			return fmt.Errorf("cancel packets may not have command set")
		}
		if r.ReqId == "" && r.ResId == "" {
			return fmt.Errorf("cancel packets must have reqid or resid set")
		}
		if r.Data != nil {
			return fmt.Errorf("cancel packets may not have data set")
		}
		return nil
	}
	if r.Command != "" {
		if r.ResId != "" {
			return fmt.Errorf("command packets may not have resid set")
		}
		if r.Error != "" {
			return fmt.Errorf("command packets may not have error set")
		}
		if r.DataType != "" {
			return fmt.Errorf("command packets may not have datatype set")
		}
		return nil
	}
	if r.ReqId != "" {
		if r.ResId == "" {
			return fmt.Errorf("request packets must have resid set")
		}
		if r.Timeout != 0 {
			return fmt.Errorf("non-command request packets may not have timeout set")
		}
		return nil
	}
	if r.ResId != "" {
		if r.Command != "" {
			return fmt.Errorf("response packets may not have command set")
		}
		if r.ReqId == "" {
			return fmt.Errorf("response packets must have reqid set")

View on GitHub (pinned to a4447c1563)

Solutions

  1. Clear DataType and put the payload in Data (marshaled per the command's MappedData type)
  2. Remove any code that pre-sets DataType on outgoing commands
  3. Round-trip a sample command through Validate in tests to catch regression

Example fix

// before
msg := wshutil.RpcMessage{Command: "controller.sendinput", DataType: "inputdata", Data: b}
// after
msg := wshutil.RpcMessage{Command: "controller.sendinput", Data: b}
Defensive patterns

Strategy: validation

Validate before calling

if msg.Command != "" {
	msg.DataType = ""
}
if err := msg.Validate(); err != nil { return err }

Type guard

func commandHasNoDataType(msg wshutil.RpcMessage) bool {
	return msg.Command == "" || msg.DataType == ""
}

Try / catch

if err := msg.Validate(); err != nil {
	return fmt.Errorf("command has datatype: %w", err)
}

Prevention

When it happens

Trigger: Calling Validate on an RpcMessage with Command set and DataType non-empty.

Common situations: Copy-paste from response-packet construction code where DataType annotates Data; helpers that stamp DataType unconditionally before sending.

Related errors


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