chenhg5/cc-connect · error
%s: reply api call: %w
Error message
%s: reply api call: %w
What it means
Wraps a transport-level failure from the Lark SDK's Im.Message.Reply call — the request never completed successfully (network error, timeout, DNS failure, or SDK-level error). Both retry layers (transient retry and fresh-token retry) have already been applied; this error escapes only if retries were exhausted or the error is non-retryable.
Source
Thrown at platform/feishu/feishu.go:4055
body := larkim.NewReplyMessageReqBodyBuilder().
MsgType(msgType).
Content(content)
if p.shouldReplyInThread(rc) {
body.ReplyInThread(true)
}
return body.Build()
}
func (p *Platform) replyMessage(ctx context.Context, rc replyContext, msgType, content string) error {
req := larkim.NewReplyMessageReqBuilder().
MessageId(rc.messageID).
Body(p.buildReplyMessageReqBody(rc, msgType, content)).
Build()
return p.withTransientRetry(ctx, "reply", func() error {
return p.withFreshTenantAccessTokenRetry(ctx, "reply", func(client *lark.Client, options ...larkcore.RequestOptionFunc) error {
resp, err := client.Im.Message.Reply(ctx, req, options...)
if err != nil {
return fmt.Errorf("%s: reply api call: %w", p.tag(), err)
}
if !resp.Success() {
return fmt.Errorf("%s: reply failed code=%d msg=%s", p.tag(), resp.Code, resp.Msg)
}
return nil
})
})
}
func (p *Platform) createMessage(ctx context.Context, chatID, msgType, content, op string) error {
req := larkim.NewCreateMessageReqBuilder().
ReceiveIdType(larkim.ReceiveIdTypeChatId).
Body(larkim.NewCreateMessageReqBodyBuilder().
ReceiveId(chatID).
MsgType(msgType).
Content(content).
Build()).
Build()View on GitHub (pinned to 4000b2338a)
Solutions
- Inspect the wrapped error (%w) for the root cause — connection vs timeout vs TLS.
- Check outbound network connectivity to the Feishu API domain from the host running cc-connect.
- If timeouts, review withTransientRetry settings or reduce message payload size.
- Verify no stale lark client is being reused; the fresh-token retry wrapper should handle auth-side failures.
Example fix
// before
return fmt.Errorf("%s: reply api call: %w", p.tag(), err)
// after
return fmt.Errorf("%s: reply api call: %w", p.tag(), err) // caller should inspect errors.Unwrap for retry/network classification Defensive patterns
Strategy: retry
Validate before calling
if err := checkConnectivity("open.feishu.cn:443"); err != nil { /* defer sends */ } Try / catch
err := p.replyMessage(ctx, rc, msgType, content)
if err != nil && isNetworkError(err) {
// queue for retry with exponential backoff
} Prevention
- Rely on the built-in withTransientRetry wrapper and tune its budget.
- Monitor egress connectivity to Feishu domains.
- Avoid oversized message payloads.
- Pin DNS resolution in containers to avoid resolution flakes.
When it happens
Trigger: client.Im.Message.Reply returns a non-nil error: network partition, TLS failure, request timeout, or SDK client construction/serialization problem while replying to a message in a Feishu chat.
Common situations: Feishu/Lark API outage, container DNS misconfiguration, proxy/firewall blocking open.feishu.cn or open.larksuite.com, or very large message content causing timeouts.
Understand the failure class
Background: "API request failed": what wrapped HTTP errors from external APIs mean and how to find the real cause — this error's family across 29 libraries.
Related errors
- %s: %s api call: %w
- %s: reply failed code=%d msg=%s
- %s: fetch tenant access token: %w
- redirected to unsupported image URL
- remote image host resolved to no usable IPs
AI-assisted analysis of chenhg5/cc-connect@4000b2338a (2026-09-06).
Data as JSON: /api/errors/f4c469025c26d9f3.
Report an issue: GitHub.