chenhg5/cc-connect · error

%s: reply failed code=%d msg=%s

Error message

%s: reply failed code=%d msg=%s

What it means

The Feishu Reply API completed at the HTTP level but returned a business error: resp.Success() is false, and the Feishu code and msg from the response body are surfaced in the error. This means Feishu explicitly refused the reply (bad message_id, permission, deleted message, etc.).

Source

Thrown at platform/feishu/feishu.go:4058

	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()
	return p.withTransientRetry(ctx, op, func() error {
		return p.withFreshTenantAccessTokenRetry(ctx, op, func(client *lark.Client, options ...larkcore.RequestOptionFunc) error {
			resp, err := client.Im.Message.Create(ctx, req, options...)

View on GitHub (pinned to 4000b2338a)

Solutions

  1. Read the code/msg in the error and cross-reference Feishu's error-code documentation.
  2. Verify the message_id being replied to still exists and the bot is a member of the chat.
  3. Ensure the app has im:message scopes granted and republished.
  4. If the code indicates rate limiting, add backoff/queueing for outgoing replies.
Defensive patterns

Strategy: try-catch

Validate before calling

// before replying, verify bot membership via chat info API
chat, err := getChatInfo(ctx, rc.chatID)
if err != nil || !chat.IsBotMember { /* skip reply */ }

Try / catch

err := p.replyMessage(ctx, rc, msgType, content)
var code int
if extractFeishuCode(err, &code) {
	switch code {
	case 99991400: // rate limited: backoff and retry
	case 230001: // message recalled: drop
	default: logAndAlert(err)
	}
}

Prevention

When it happens

Trigger: client.Im.Message.Reply returns a response where Success()==false — e.g. invalid message_id to reply to, bot removed from chat, missing im:message:send_as_bot scope, or rate limiting code.

Common situations: Replying to a message that has been recalled/deleted, bot kicked from the group, app scope changes not republished, or hitting Feishu QPS limits (code 99991400).

Related errors


AI-assisted analysis of chenhg5/cc-connect@4000b2338a (2026-09-06). Data as JSON: /api/errors/b8061e0509e6c2bf. Report an issue: GitHub.