{"record":{"id":"d88d18c81b7c5cc3","repo":"chenhg5/cc-connect","slug":"s-s-api-call-w","errorCode":null,"errorMessage":"%s: %s api call: %w","messagePattern":"(.+?): (.+?) api call: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"platform/feishu/feishu.go","lineNumber":4078,"sourceCode":"\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...)\n\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"%s: %s api call: %w\", p.tag(), op, err)\n\t\t\t}\n\t\t\tif !resp.Success() {\n\t\t\t\treturn fmt.Errorf(\"%s: %s failed code=%d msg=%s\", p.tag(), op, resp.Code, resp.Msg)\n\t\t\t}\n\t\t\treturn nil\n\t\t})\n\t})\n}\n\nfunc (p *Platform) withFreshTenantAccessTokenRetry(ctx context.Context, operation string, fn feishuRequestFunc) error {\n\terr := fn(p.client)\n\tif !isTenantAccessTokenInvalid(err) {\n\t\treturn err\n\t}\n\n\tfreshToken, refreshErr := p.fetchFreshTenantAccessToken(ctx)\n\tif refreshErr != nil {\n\t\treturn fmt.Errorf(\"%s: %s failed after token refresh attempt: %w (original error: %v)\", p.tag(), operation, refreshErr, err)","sourceCodeStart":4060,"sourceCodeEnd":4096,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/platform/feishu/feishu.go#L4060-L4096","documentation":"Wraps a transport-level failure from the Lark SDK's Im.Message.Create call (sending a new message). Analogous to the reply-path error: the HTTP request itself failed before Feishu could return a business result, after transient and token-refresh retries were exhausted or deemed inapplicable.","triggerScenarios":"client.Im.Message.Create returns a non-nil error while sending a new message to a chat (receive_id=chat_id): network outage, DNS failure, TLS error, timeout, or request construction failure.","commonSituations":"Feishu API downtime, host without outbound internet access, proxy intercepting HTTPS, or invalid receive_id_type causing an SDK-level error.","solutions":["Inspect the wrapped error to distinguish network vs serialization causes.","Test connectivity: curl https://open.feishu.cn from the host.","Confirm receive_id_type and receive_id (chat_id) are valid in the request builder.","Review withTransientRetry configuration if the failure is transient flakiness."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"if err := checkConnectivity(\"open.feishu.cn:443\"); err != nil { /* defer send */ }","typeGuard":null,"tryCatchPattern":"err := p.sendMessage(ctx, chatID, msgType, content)\nif err != nil && errors.Is(err, context.DeadlineExceeded) {\n\t// retry once with longer timeout\n}","preventionTips":["Set sane request timeouts on the lark client.","Keep message content within Feishu size limits.","Monitor API latency/error rates per operation.","Ensure receive_id_type matches the identifier you pass."],"tags":["feishu","lark","network","api-call","send"],"backgroundTag":"api-request-failed","analyzedSha":"4000b2338aa6e850c99df54f8b0ed6ed7460b401","analyzedAt":"2026-09-06T11:45:09.575Z","contentChangedAt":"2026-09-06T11:45:09.575Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}