chenhg5/cc-connect · critical
getMe: %w
Error message
getMe: %w
What it means
During bot setup, defaultNewBot calls the Telegram getMe API (with a 10s timeout) to identify the bot. Any getMe failure — invalid token, network problem, Telegram API outage — is wrapped as "getMe: %w" so the underlying cause is preserved.
Source
Thrown at platform/telegram/telegram.go:271
handler := func(ctx context.Context, b *tgbot.Bot, update *models.Update) {
onUpdate(ctx, update)
}
opts := []tgbot.Option{
tgbot.WithDefaultHandler(handler),
tgbot.WithNotAsyncHandlers(),
}
if httpClient != nil {
opts = append(opts, tgbot.WithHTTPClient(60*time.Second, httpClient))
}
b, err := tgbot.New(token, opts...)
if err != nil {
return nil, nil, nil, err
}
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()
me, err := b.GetMe(ctx)
if err != nil {
return nil, nil, nil, fmt.Errorf("getMe: %w", err)
}
// Drain pending updates before starting polling to avoid 409 Conflict.
// This clears any outstanding long-poll request from a previous instance.
drainPendingUpdates(token, httpClient)
return b, me, b.Start, nil
}
// drainPendingUpdates clears any pending updates on Telegram's side by calling
// getUpdates with offset=-1. This terminates any outstanding long-poll request
// from a previous bot instance, preventing 409 Conflict errors on restart.
func drainPendingUpdates(token string, httpClient *http.Client) {
apiURL := "https://api.telegram.org/bot" + token + "/getUpdates?offset=-1&timeout=0"
client := httpClient
if client == nil {
client = http.DefaultClient
}View on GitHub (pinned to 4000b2338a)
Solutions
- Verify the bot token with: curl https://api.telegram.org/bot<TOKEN>/getMe
- Check network/proxy connectivity to api.telegram.org from the host
- If behind a proxy, set the proxy/proxy_username/proxy_password options correctly
- Retry after a transient outage — Start's retry loop may recover on reconnect
Defensive patterns
Strategy: retry
Validate before calling
resp, err := http.Get("https://api.telegram.org/bot" + token + "/getMe")
// non-200 or ok=false in the JSON body means the token/network is bad before Start Try / catch
if err := plat.Start(handler); err != nil {
if strings.Contains(err.Error(), "getMe:") {
// transient? retry with backoff after checking token/network
return retryWithBackoff(func() error { return plat.Start(handler) })
}
return err
} Prevention
- Validate the token with a getMe curl before deploying
- Confirm api.telegram.org reachability (firewall, proxy, DNS)
- Provide proxy options if the host requires one
- Avoid multiple pollers on the same token to reduce API conflicts
When it happens
Trigger: defaultNewBot invoked during Start() when the Telegram Bot API rejects the token (401), is unreachable (DNS/firewall/proxy down), or the 10-second context deadline expires.
Common situations: Revoked or mistyped bot token; no outbound internet or blocked access to api.telegram.org; misconfigured proxy; Telegram API regional outage; slow network exceeding the 10s timeout.
Understand the failure class
Background: "API error: {status}" and "HTTP 401/403/404/429/5xx" errors: non-2xx HTTP responses explained — this error's family across 27 libraries.
Related errors
- telegram: send preview: %w
- remote returned non-zero code
- http %d: %s
- whisper API %d: %s
- get access token: %w
AI-assisted analysis of chenhg5/cc-connect@4000b2338a (2026-09-06).
Data as JSON: /api/errors/be4f23903ba4d95d.
Report an issue: GitHub.