sipeed/picoclaw · error

invalid thread ID in chat ID

Error message

invalid thread ID in chat ID %q: %w

What it means

Guard in parseTelegramChatID: the "chatID/threadID" compound form had a parseable chat portion, but strconv rejected the thread-ID segment after the slash (non-numeric or out-of-range int). The %w wraps that strconv error; forum topics rely on this split to target the right thread.

Solutions

  1. Ensure the thread portion after / is a plain integer topic ID
  2. Remove the /threadID suffix when targeting the channel's main feed
  3. Check for stray characters or whitespace in the compound chat ID
Defensive patterns

Strategy: validation

When it happens

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

Appendix: source

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

func (c *TelegramChannel) ToolFeedbackMessageChatID(chatID string, outboundCtx *bus.InboundContext) string {
	return telegramToolFeedbackChatKey(chatID, outboundCtx)
}

// parseTelegramChatID splits "chatID/threadID" into its components.
// Returns threadID=0 when no "/" is present (non-forum messages).
func parseTelegramChatID(chatID string) (int64, int, error) {
	idx := strings.Index(chatID, "/")
	if idx == -1 {
		cid, err := strconv.ParseInt(chatID, 10, 64)
		return cid, 0, err
	}
	cid, err := strconv.ParseInt(chatID[:idx], 10, 64)
	if err != nil {
		return 0, 0, err
	}
	tid, err := strconv.Atoi(chatID[idx+1:])
	if err != nil {
		return 0, 0, fmt.Errorf("invalid thread ID in chat ID %q: %w", chatID, err)
	}
	return cid, tid, nil
}

func resolveTelegramOutboundTarget(chatID string, outboundCtx *bus.InboundContext) (int64, int, error) {
	targetChatID := strings.TrimSpace(chatID)
	if targetChatID == "" && outboundCtx != nil {
		targetChatID = strings.TrimSpace(outboundCtx.ChatID)
	}
	resolvedChatID, resolvedThreadID, err := parseTelegramChatID(targetChatID)
	if err != nil {
		return 0, 0, err
	}
	if resolvedThreadID != 0 || outboundCtx == nil {
		return resolvedChatID, resolvedThreadID, nil
	}
	topicID := strings.TrimSpace(outboundCtx.TopicID)
	if topicID == "" {

View on GitHub (pinned to 49183d7e8d)