sipeed/picoclaw · error · ErrTemporary

telegram send

Error message

telegram send: %w

What it means

Returned by sendChunk after a double failure: the initial SendMessage errored (usually markdown parse issues), logParseFailed ran, and the retry with the plain-text fallback also failed. The final error wraps channels.ErrTemporary, marking the failure transient so callers can retry rather than drop the message.

Solutions

  1. Retry after backoff — the error is classified as temporary (network blip or rate limit)
  2. Check for 429 rate limiting from Telegram and slow down send volume
  3. If persistent, verify network connectivity and bot token validity
  4. Check logs from the first attempt to see whether markdown parsing forced the fallback path
Defensive patterns

Strategy: retry

When it happens

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

Appendix: source

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

	}

	if params.replyToID != "" {
		if mid, parseErr := strconv.Atoi(params.replyToID); parseErr == nil {
			tgMsg.ReplyParameters = &telego.ReplyParameters{
				MessageID: mid,
			}
		}
	}

	pMsg, err := c.bot.SendMessage(ctx, tgMsg)
	if err != nil {
		logParseFailed(err, params.useMarkdownV2)

		tgMsg.Text = params.mdFallback
		tgMsg.ParseMode = ""
		pMsg, err = c.bot.SendMessage(ctx, tgMsg)
		if err != nil {
			return "", fmt.Errorf("telegram send: %w", channels.ErrTemporary)
		}
	}

	return strconv.Itoa(pMsg.MessageID), nil
}

// maxTypingDuration limits how long the typing indicator can run.
// Prevents endless typing when the LLM fails/hangs and preSend never invokes cancel.
// Matches channels.Manager's typingStopTTL (5 min) so behavior is consistent.
const maxTypingDuration = 5 * time.Minute

// StartTyping implements channels.TypingCapable.
// It sends ChatAction(typing) immediately and then repeats every 4 seconds
// (Telegram's typing indicator expires after ~5s) in a background goroutine.
// The returned stop function is idempotent and cancels the goroutine.
// The goroutine also exits automatically after maxTypingDuration if cancel is
// never called (e.g. when the LLM fails or times out without publishing).
func (c *TelegramChannel) StartTyping(ctx context.Context, chatID string) (func(), error) {

View on GitHub (pinned to 49183d7e8d)