sipeed/picoclaw · error
create chat by contact returned empty id
Error message
create chat by contact returned empty id: %w
What it means
Sanity guard in chatIDForContact: chat creation succeeded and decoded, but the returned chatID is <= 0, which cannot be a valid chat handle. The error wraps the channels.ErrSendFailed sentinel so callers can classify it as a send-path failure; the fault is with the core's response payload, not the request.
Solutions
- Treat as a core-side anomaly: log the raw response for the RPC
- Verify the contact id passed in is positive and exists
- Retry once — transient core glitches can return 0
- Match on errors.Is(err, channels.ErrSendFailed) at the caller for send-flow handling
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at pkg/channels/deltachat/deltachat.go:649 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/a8193cfadaaf7651.
Report an issue: GitHub.
Appendix: source
Thrown at pkg/channels/deltachat/deltachat.go:649
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)
}
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)View on GitHub (pinned to 49183d7e8d)