sipeed/picoclaw · error

empty chat id

Error message

empty chat id

What it means

Returned by parseJID in the native WhatsApp channel when the chat id is empty after strings.TrimSpace. It is a plain error (no sentinel), typically surfaced to callers wrapped as 'invalid chat id %q: empty chat id' by Send. It indicates an upstream data problem: an empty/whitespace recipient reached the channel.

Source

Thrown at pkg/channels/whatsapp_native/whatsapp_native.go:453

	if err != nil {
		return nil, fmt.Errorf("invalid chat id %q: %w", msg.ChatID, err)
	}

	waMsg := &waE2E.Message{
		Conversation: proto.String(msg.Content),
	}

	if _, err = client.SendMessage(ctx, to, waMsg); err != nil {
		return nil, fmt.Errorf("whatsapp send: %w", channels.ErrTemporary)
	}
	return nil, nil
}

// parseJID converts a chat ID (phone number or JID string) to types.JID.
func parseJID(s string) (types.JID, error) {
	s = strings.TrimSpace(s)
	if s == "" {
		return types.JID{}, fmt.Errorf("empty chat id")
	}
	if strings.Contains(s, "@") {
		return types.ParseJID(s)
	}
	return types.NewJID(s, types.DefaultUserServer), nil
}

View on GitHub (pinned to 49183d7e8d)

Solutions

  1. Populate msg.ChatID with a phone number ('15551234567') or JID ('15551234567@s.whatsapp.net') before sending.
  2. Add a non-empty check at the call site or in your message-building code.
  3. Audit upstream routing for where the empty destination originated.
  4. Treat as permanent - do not retry; drop or dead-letter such messages.

Example fix

// before
msg := bus.OutboundMessage{ChatID: cfg.Recipient, Content: text} // cfg.Recipient == ""
// after
if strings.TrimSpace(cfg.Recipient) == "" {
    return fmt.Errorf("recipient not configured")
}
msg := bus.OutboundMessage{ChatID: cfg.Recipient, Content: text}
Defensive patterns

Strategy: validation

Validate before calling

if strings.TrimSpace(msg.ChatID) == "" {
    return errors.New("refusing to send: empty chat id")
}

Try / catch

if _, err := ch.Send(ctx, msg); err != nil {
    if strings.Contains(err.Error(), "empty chat id") {
        // permanent input bug: fix producer; do not retry
    }
}

Prevention

When it happens

Trigger: Send() called with msg.ChatID == "" or containing only spaces/tabs; upstream router forwarded a message whose destination was never populated.

Common situations: Automation/bridge code building outbound messages with an unset ChatID field; config templates with an empty recipient placeholder; trimming bugs that reduce ids to whitespace.

Related errors


AI-assisted analysis of sipeed/picoclaw@49183d7e8d (2026-08-15). Data as JSON: /api/errors/ba36c1347681588d. Report an issue: GitHub.