sipeed/picoclaw · error
failed to marshal response
Error message
failed to marshal response: %w
What it means
Raised in MaixCamChannel.Send when json.Marshal of the outbound command map fails. In practice nearly impossible for a map of string/number values, but it guards against any unexpected content type in the payload.
Solutions
- Inspect msg.Content and msg.ChatID for unsupported or hostile values
- No retry helps; fix the payload construction
- Log the marshal error for diagnosis
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at pkg/channels/maixcam/maixcam.go:274 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of sipeed/picoclaw@49183d7e8d (2026-08-15).
Data as JSON: /api/errors/d3c4161f558a5553.
Report an issue: GitHub.
Appendix: source
Thrown at pkg/channels/maixcam/maixcam.go:274
c.clientsMux.RLock()
defer c.clientsMux.RUnlock()
if len(c.clients) == 0 {
logger.WarnC("maixcam", "No MaixCam devices connected")
return nil, fmt.Errorf("no connected MaixCam devices")
}
response := map[string]any{
"type": "command",
"timestamp": float64(0),
"message": msg.Content,
"chat_id": msg.ChatID,
}
data, err := json.Marshal(response)
if err != nil {
return nil, fmt.Errorf("failed to marshal response: %w", err)
}
var sendErr error
for conn := range c.clients {
_ = conn.SetWriteDeadline(time.Now().Add(10 * time.Second))
if _, err := conn.Write(data); err != nil {
logger.ErrorCF("maixcam", "Failed to send to client", map[string]any{
"client": conn.RemoteAddr().String(),
"error": err.Error(),
})
sendErr = fmt.Errorf("maixcam send: %w", channels.ErrTemporary)
}
_ = conn.SetWriteDeadline(time.Time{})
}
return nil, sendErr
}
View on GitHub (pinned to 49183d7e8d)