wavetermdev/waveterm · error
command packets may not have resid set
Error message
command packets may not have resid set
What it means
Packet validation error: COMMAND packets must not set resid. A resid is assigned to responses/cancels to correlate with a request; a fresh command cannot reference one, so such a packet is rejected.
Source
Thrown at pkg/wshutil/wshrpc.go:163
func (r *RpcMessage) Validate() error {
if r.ReqId != "" && r.ResId != "" {
return fmt.Errorf("request packets may not have both reqid and resid set")
}
if r.Cancel {
if r.Command != "" {
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
}View on GitHub (pinned to a4447c1563)
Solutions
- Clear ResId on the outgoing command packet
- Set Command = "" if the message is really a response
- Validate the message right after construction to catch field leakage early
Example fix
// before
msg := wshutil.RpcMessage{Command: "event.subscribe", ResId: incomingResId}
// after
msg := wshutil.RpcMessage{Command: "event.subscribe"} Defensive patterns
Strategy: validation
Validate before calling
if msg.Command != "" {
msg.ResId = ""
}
if err := msg.Validate(); err != nil { return err } Type guard
func isCommandNotResponse(msg wshutil.RpcMessage) bool {
return msg.Command != "" && msg.ResId == ""
} Try / catch
if err := msg.Validate(); err != nil {
return fmt.Errorf("command packet carries resid: %w", err)
} Prevention
- Clear incoming-message fields before reusing a struct for an outgoing command
- Use distinct types/constructors for requests vs responses
- Validate before send in debug mode
When it happens
Trigger: Calling Validate on an RpcMessage with Command set and ResId non-empty (with Cancel false).
Common situations: A responder that echoes the incoming message struct back and forgets to clear ResId before setting Command; middleware rewriting packets between directions.
Related errors
- request packets may not have both reqid and resid set
- blockid is required
- size must be greater than 0
- invalid context, must have a routeid
- cancel packets may not have command set
AI-assisted analysis of wavetermdev/waveterm@a4447c1563 (2026-09-01).
Data as JSON: /api/errors/dfb223a8ed9281c1.
Report an issue: GitHub.