{"record":{"id":"29ef43b70942ad72","repo":"chenhg5/cc-connect","slug":"s-upload-file-code-d-msg-s","errorCode":null,"errorMessage":"%s: upload file code=%d msg=%s","messagePattern":"(.+?): upload file code=(.+?) msg=(.+?)","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"platform/feishu/feishu.go","lineNumber":3338,"sourceCode":"\t}\n\tfileType := detectFeishuFileType(file.MimeType, fileName)\n\tvar uploadResp *larkim.CreateFileResp\n\tif err := p.withTransientRetry(ctx, \"upload file\", func() error {\n\t\treturn p.withFreshTenantAccessTokenRetry(ctx, \"upload file\", func(client *lark.Client, options ...larkcore.RequestOptionFunc) error {\n\t\t\treq := larkim.NewCreateFileReqBuilder().\n\t\t\t\tBody(larkim.NewCreateFileReqBodyBuilder().\n\t\t\t\t\tFileType(fileType).\n\t\t\t\t\tFileName(fileName).\n\t\t\t\t\tFile(bytes.NewReader(file.Data)).\n\t\t\t\t\tBuild()).\n\t\t\t\tBuild()\n\t\t\tvar err error\n\t\t\tuploadResp, err = client.Im.File.Create(ctx, req, options...)\n\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"%s: upload file: %w\", p.tag(), err)\n\t\t\t}\n\t\t\tif !uploadResp.Success() {\n\t\t\t\treturn fmt.Errorf(\"%s: upload file code=%d msg=%s\", p.tag(), uploadResp.Code, uploadResp.Msg)\n\t\t\t}\n\t\t\treturn nil\n\t\t})\n\t}); err != nil {\n\t\treturn err\n\t}\n\tif uploadResp.Data == nil || uploadResp.Data.FileKey == nil {\n\t\treturn fmt.Errorf(\"%s: upload file: no file_key returned\", p.tag())\n\t}\n\n\tmsgType := detectFeishuFileMessageType(fileType)\n\tfileContent, err := buildFeishuFileMessageContent(msgType, *uploadResp.Data.FileKey)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"%s: build file message: %w\", p.tag(), err)\n\t}\n\n\treturn p.sendMediaMessage(ctx, rc, msgType, fileContent)\n}","sourceCodeStart":3320,"sourceCodeEnd":3356,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/platform/feishu/feishu.go#L3320-L3356","documentation":"The Feishu file upload API responded but with a business error: uploadResp.Success() is false. The library surfaces the API's numeric code and message so the developer can identify the Feishu-side failure (permissions, file constraints, rate limits).","triggerScenarios":"client.Im.File.Create returns a success-flag-false response at platform/feishu/feishu.go:3338 — e.g. code 230002 (file too large, Feishu limit ~30MB), 99991672 (no permission), or 1254045 rate limit.","commonSituations":"Uploading files larger than Feishu's 30MB limit, unsupported file_type for the Im.File.Create request, app missing im:resource permission, bot throttled by Feishu.","solutions":["Look up the printed code in Feishu's open-platform error code list.","Check/raise against the 30MB file size limit; compress or split large files before upload.","Grant im:resource permission to the app and republish the app version.","Back off and retry if the code indicates rate limiting."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Pre-check: file type must be one of Feishu-supported Im.File.Create types\n// (opus, mp4, pdf, doc, xls, ppt, stream) and size <= 30MB.","typeGuard":null,"tryCatchPattern":"err := p.SendFile(ctx, rc, file)\nif err != nil && strings.Contains(err.Error(), \"upload file code=\") {\n    // parse code=N from message and branch on known Feishu error codes\n}","preventionTips":["Match the uploaded file to a supported file_type; don't upload arbitrary binaries as media types.","Split or compress files above 30MB before upload.","Watch for rate-limit codes and apply backoff.","Audit app permission versions after each Feishu console change."],"tags":["feishu","upload","file","api-error"],"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-14T05:17:10.506Z"}