{"record":{"id":"b8061e0509e6c2bf","repo":"chenhg5/cc-connect","slug":"s-reply-failed-code-d-msg-s","errorCode":null,"errorMessage":"%s: reply failed code=%d msg=%s","messagePattern":"(.+?): reply failed code=(.+?) msg=(.+?)","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"platform/feishu/feishu.go","lineNumber":4058,"sourceCode":"\tif p.shouldReplyInThread(rc) {\n\t\tbody.ReplyInThread(true)\n\t}\n\treturn body.Build()\n}\n\nfunc (p *Platform) replyMessage(ctx context.Context, rc replyContext, msgType, content string) error {\n\treq := larkim.NewReplyMessageReqBuilder().\n\t\tMessageId(rc.messageID).\n\t\tBody(p.buildReplyMessageReqBody(rc, msgType, content)).\n\t\tBuild()\n\treturn p.withTransientRetry(ctx, \"reply\", func() error {\n\t\treturn p.withFreshTenantAccessTokenRetry(ctx, \"reply\", func(client *lark.Client, options ...larkcore.RequestOptionFunc) error {\n\t\t\tresp, err := client.Im.Message.Reply(ctx, req, options...)\n\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"%s: reply api call: %w\", p.tag(), err)\n\t\t\t}\n\t\t\tif !resp.Success() {\n\t\t\t\treturn fmt.Errorf(\"%s: reply failed code=%d msg=%s\", p.tag(), resp.Code, resp.Msg)\n\t\t\t}\n\t\t\treturn nil\n\t\t})\n\t})\n}\n\nfunc (p *Platform) createMessage(ctx context.Context, chatID, msgType, content, op string) error {\n\treq := larkim.NewCreateMessageReqBuilder().\n\t\tReceiveIdType(larkim.ReceiveIdTypeChatId).\n\t\tBody(larkim.NewCreateMessageReqBodyBuilder().\n\t\t\tReceiveId(chatID).\n\t\t\tMsgType(msgType).\n\t\t\tContent(content).\n\t\t\tBuild()).\n\t\tBuild()\n\treturn p.withTransientRetry(ctx, op, func() error {\n\t\treturn p.withFreshTenantAccessTokenRetry(ctx, op, func(client *lark.Client, options ...larkcore.RequestOptionFunc) error {\n\t\t\tresp, err := client.Im.Message.Create(ctx, req, options...)","sourceCodeStart":4040,"sourceCodeEnd":4076,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/platform/feishu/feishu.go#L4040-L4076","documentation":"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.).","triggerScenarios":"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.","commonSituations":"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).","solutions":["Read the code/msg in the error and cross-reference Feishu's error-code documentation.","Verify the message_id being replied to still exists and the bot is a member of the chat.","Ensure the app has im:message scopes granted and republished.","If the code indicates rate limiting, add backoff/queueing for outgoing replies."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// before replying, verify bot membership via chat info API\nchat, err := getChatInfo(ctx, rc.chatID)\nif err != nil || !chat.IsBotMember { /* skip reply */ }","typeGuard":null,"tryCatchPattern":"err := p.replyMessage(ctx, rc, msgType, content)\nvar code int\nif extractFeishuCode(err, &code) {\n\tswitch code {\n\tcase 99991400: // rate limited: backoff and retry\n\tcase 230001: // message recalled: drop\n\tdefault: logAndAlert(err)\n\t}\n}","preventionTips":["Grant and republish im:message scopes before rollout.","Handle recalled-message codes gracefully by dropping the send.","Add rate-limit backoff on QPS error codes.","Alert on unknown Feishu codes to catch scope/chat changes early."],"tags":["feishu","lark","api","reply","error-code"],"backgroundTag":"api-error-response","analyzedSha":"4000b2338aa6e850c99df54f8b0ed6ed7460b401","analyzedAt":"2026-09-06T11:45:09.575Z","contentChangedAt":"2026-09-06T11:45:09.575Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}