sipeed/picoclaw · error
decode
Error message
%s decode: %w
What it means
Generic decode helper in decodeOptionalInt64: the raw JSON-RPC payload failed to unmarshal into *int64 for the labeled method (the %s in the message, e.g. 'get chat by contact'). Because the target is a pointer type, a JSON null decodes to nil (no chat) without error — this error only fires when the payload is genuinely the wrong shape (string, object, array).
Solutions
- Log the raw payload alongside the label to identify the shape mismatch
- Align the decode target with the DeltaChat core's actual response format
- Handle null explicitly (nil pointer) before decoding when absent values are meaningful
- Pin a core version whose RPC response shapes match this decoder
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at pkg/channels/deltachat/deltachat.go:657 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/32510a45b5947ea0.
Report an issue: GitHub.
Appendix: source
Thrown at pkg/channels/deltachat/deltachat.go:657
}
raw, err = c.rpc.call(ctx, "create_chat_by_contact_id", c.accountID, contactID)
if err != nil {
return 0, fmt.Errorf("create chat by contact: %w", err)
}
if err := json.Unmarshal(raw, &chatID); err != nil {
return 0, fmt.Errorf("create chat by contact decode: %w", err)
}
if chatID <= 0 {
return 0, fmt.Errorf("create chat by contact returned empty id: %w", channels.ErrSendFailed)
}
return chatID, nil
}
func decodeOptionalInt64(raw json.RawMessage, label string) (int64, error) {
var id *int64
if err := json.Unmarshal(raw, &id); err != nil {
return 0, fmt.Errorf("%s decode: %w", label, err)
}
if id == nil {
return 0, nil
}
return *id, nil
}
func (c *DeltaChatChannel) resolveAliasChatID(ctx context.Context, target string) (int64, error) {
for _, query := range aliasQueries(target) {
contacts, err := c.findMatchingContacts(ctx, query)
if err != nil {
return 0, err
}
if len(contacts) == 1 {
return c.chatIDForContact(ctx, contacts[0].ID)
}
if len(contacts) > 1 {
return 0, ambiguousRecipientError(target, contactRecipientLabels(contacts))View on GitHub (pinned to 49183d7e8d)