sipeed/picoclaw · error
get chat by contact
Error message
get chat by contact: %w
What it means
Context wrapper in DeltaChatChannel.chatIDForContact around the 'get_chat_id_by_contact_id' JSON-RPC call: the DeltaChat core RPC failed, meaning no existing chat could be looked up for the contact. The call site treats this as fatal for contact resolution; a chatID of 0 (no chat yet) is NOT an error — that case falls through to chat creation.
Solutions
- Check that the DeltaChat RPC server is running and the accountID is valid
- Inspect the wrapped RPC error for method-level failures
- Retry on transient transport errors to the RPC socket
- Ensure the contact exists before resolving its chat
Defensive patterns
Strategy: retry
When it happens
Trigger: Thrown at pkg/channels/deltachat/deltachat.go:631 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/0ca4cc6e740955d6.
Report an issue: GitHub.
Appendix: source
Thrown at pkg/channels/deltachat/deltachat.go:631
}
raw, err := c.rpc.call(ctx, "create_contact", c.accountID, address, displayName)
if err != nil {
return 0, fmt.Errorf("create contact: %w", err)
}
var contactID int64
if err := json.Unmarshal(raw, &contactID); err != nil {
return 0, fmt.Errorf("create contact decode: %w", err)
}
if contactID <= 0 {
return 0, fmt.Errorf("create contact returned empty id: %w", channels.ErrSendFailed)
}
return contactID, nil
}
func (c *DeltaChatChannel) chatIDForContact(ctx context.Context, contactID int64) (int64, error) {
raw, err := c.rpc.call(ctx, "get_chat_id_by_contact_id", c.accountID, contactID)
if err != nil {
return 0, fmt.Errorf("get chat by contact: %w", err)
}
chatID, err := decodeOptionalInt64(raw, "get chat by contact")
if err != nil {
return 0, err
}
if chatID > 0 {
return chatID, nil
}
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)View on GitHub (pinned to 49183d7e8d)