wavetermdev/waveterm · error
response packets may not have command set
Error message
response packets may not have command set
What it means
Validate() in pkg/wshutil/wshrpc.go checks that each RpcMessage conforms to the packet protocol. A response packet is identified by having ResId set; responses are only acknowledgments/data for a prior request, so they must never carry a Command. This error means a packet marked as a response was built with a command field filled in.
Source
Thrown at pkg/wshutil/wshrpc.go:184
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")
}
if r.Timeout != 0 {
return fmt.Errorf("response packets may not have timeout set")
}
return nil
}
return fmt.Errorf("invalid packet: must have command, reqid, or resid set")
}
type rpcData struct {
Command string
Route string
ResCh chan *RpcMessage
Handler *RpcRequestHandler
}View on GitHub (pinned to a4447c1563)
Solutions
- Remove the Command field from the response packet; keep only ResId, ReqId, and the response data.
- If you intended to send a new command, clear ResId instead and set Command/ReqId as a request packet.
- Use SendResponse/SendResponseError on RpcResponseHandler rather than hand-building response RpcMessages.
- Run Validate() on locally built packets in tests to catch malformed shapes early.
Example fix
// before
msg := wshrpc.RpcMessage{Command: "waveclient:get", ResId: "res-1", ReqId: "req-1"}
// after
msg := wshrpc.RpcMessage{ResId: "res-1", ReqId: "req-1"} Defensive patterns
Strategy: validation
Validate before calling
func validRes(m wshrpc.RpcMessage) error {
if m.ResId != "" && m.Command != "" {
return fmt.Errorf("response packet has command set: %v", m.Command)
}
return nil
} Type guard
func isPureResponse(m wshrpc.RpcMessage) bool {
return m.ResId != "" && m.Command == ""
} Prevention
- Never reuse request structs/messages to build responses — construct fresh RpcMessage values.
- Route all responses through RpcResponseHandler.SendResponse instead of manual packet assembly.
- Run Validate() in unit tests on every packet shape your code emits.
- Clear Command/Timeout fields when transforming requests into responses.
When it happens
Trigger: Manually constructing or marshaling an RpcMessage with both ResId and Command set, or replying via a response path while accidentally copying the original request's Command field into the reply.
Common situations: Custom RPC client code that echoes request fields into responses; version drift where one side serializes packets with command carried over; hand-written test fixtures for WSH RPC messages.
Related errors
- response packets must have reqid set
- response packets may not have timeout set
- invalid packet: must have command, reqid, or resid set
- call ${methodName} error: ${respData.error}
- rpc command "${msg.command}" not supported by [${this.routeI
AI-assisted analysis of wavetermdev/waveterm@a4447c1563 (2026-09-01).
Data as JSON: /api/errors/c98fc990851daa33.
Report an issue: GitHub.