sipeed/picoclaw · error · ErrSendFailed

invalid chat ID

Error message

invalid chat ID %s: %w

What it means

Guard in TelegramChannel.Send: resolveTelegramOutboundTarget could not resolve the outbound chat ID to a chat the bot may message (unparseable numeric ID, cross-chat target denied by default policy, or non-numeric recipient without session scope). The real resolution error is discarded and replaced with the sentinel channels.ErrSendFailed, so the %w wraps a generic failure rather than the cause.

Solutions

  1. Confirm msg.ChatID is a valid Telegram chat ID (numeric, possibly "chatID/threadID" for forums)
  2. For cross-chat sends, configure explicit allow rules — numeric targets outside the session are denied by default
  3. Ensure inbound sessions established recipient scope before sending to non-numeric identifiers
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at pkg/channels/telegram/telegram.go:227 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/de60572c03c1fc21. Report an issue: GitHub.

Appendix: source

Thrown at pkg/channels/telegram/telegram.go:227

		c.progress.StopAll()
	}
	if c.commandRegCancel != nil {
		c.commandRegCancel()
	}

	return nil
}

func (c *TelegramChannel) Send(ctx context.Context, msg bus.OutboundMessage) ([]string, error) {
	if !c.IsRunning() {
		return nil, channels.ErrNotRunning
	}

	useMarkdownV2 := c.tgCfg.UseMarkdownV2

	chatID, threadID, err := resolveTelegramOutboundTarget(msg.ChatID, &msg.Context)
	if err != nil {
		return nil, fmt.Errorf("invalid chat ID %s: %w", msg.ChatID, channels.ErrSendFailed)
	}

	if msg.Content == "" {
		return nil, nil
	}

	isToolFeedback := outboundMessageIsToolFeedback(msg)
	toolFeedbackContent := msg.Content
	if isToolFeedback {
		toolFeedbackContent = fitToolFeedbackForTelegram(msg.Content, useMarkdownV2, 4096)
	}
	trackedChatID := telegramToolFeedbackChatKey(msg.ChatID, &msg.Context)
	if isToolFeedback {
		if msgID, handled, err := c.progress.Update(ctx, trackedChatID, toolFeedbackContent); handled {
			if err != nil {
				return nil, err
			}
			return []string{msgID}, nil

View on GitHub (pinned to 49183d7e8d)