sipeed/picoclaw · error

create chat by contact: %w

Error message

create chat by contact: %w

What it means

Error "create chat by contact: %w" thrown in sipeed/picoclaw.

Source

Thrown at pkg/channels/deltachat/deltachat.go:643

	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)
	}
	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
	}

View on GitHub (pinned to 49183d7e8d)

When it happens

Trigger: Thrown at pkg/channels/deltachat/deltachat.go:643 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/95b416347404316d. Report an issue: GitHub.