{"record":{"id":"4d0be395fb90256f","repo":"chenhg5/cc-connect","slug":"s-upload-audio-code-d-msg-s","errorCode":null,"errorMessage":"%s: upload audio code=%d msg=%s","messagePattern":"(.+?): upload audio code=(.+?) msg=(.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"platform/feishu/feishu.go","lineNumber":5495,"sourceCode":"\t}\n\n\tvar uploadResp *larkim.CreateFileResp\n\tif err := p.withTransientRetry(ctx, \"upload audio\", func() error {\n\t\treturn p.withFreshTenantAccessTokenRetry(ctx, \"upload audio\", 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(larkim.FileTypeOpus).\n\t\t\t\t\tFileName(\"tts_audio.opus\").\n\t\t\t\t\tFile(bytes.NewReader(audio)).\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 audio: %w\", p.tag(), err)\n\t\t\t}\n\t\t\tif !uploadResp.Success() {\n\t\t\t\treturn fmt.Errorf(\"%s: upload audio 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 audio: no file_key returned\", p.tag())\n\t}\n\tfileKey := *uploadResp.Data.FileKey\n\n\tslog.Debug(p.tag()+\": audio uploaded\", \"file_key\", fileKey, \"format\", format, \"size\", len(audio))\n\n\taudioMsg := larkim.MessageAudio{FileKey: fileKey}\n\taudioContent, err := audioMsg.String()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"%s: build audio message: %w\", p.tag(), err)\n\t}","sourceCodeStart":5477,"sourceCodeEnd":5513,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/platform/feishu/feishu.go#L5477-L5513","documentation":"The Feishu file-upload API returned HTTP success but a business-error body: uploadResp.Success() is false. The error surfaces the numeric Feishu code and msg. This is an API-level rejection of the upload itself — typically file constraints, permissions, or app configuration — not a transport problem.","triggerScenarios":"client.Im.File.Create completes but the response body carries a non-zero code: file too large or wrong type for the im file endpoint, missing im:resource scope, invalid file_type parameter, or app not approved for the workspace.","commonSituations":"Audio exceeding Feishu's upload size limit; bot app missing im:resource permission in the Feishu admin console; uploading to a tenant where the app is not installed/approved; Feishu-side API changes after version updates.","solutions":["Look up the specific code=%d in Feishu's error-code documentation","Grant the bot im:resource (file upload) scope and republish","Check the audio size/duration against Feishu upload limits","Confirm the app is installed and approved in the target tenant/workspace"],"exampleFix":"// before: ignoring the coded error\nif err := p.SendAudio(ctx, rc, audio, \"opus\"); err != nil { return nil }\n// after\nif err := p.SendAudio(ctx, rc, audio, \"opus\"); err != nil {\n    if strings.Contains(err.Error(), \"code=230013\") { slog.Warn(\"feishu: file too large\") }\n    return err\n}","handlingStrategy":"validation","validationCode":"// before upload: check audio size\nconst maxFeishuUpload = 30 << 20 // check current Feishu limit\nif len(audio) > maxFeishuUpload { return errors.New(\"audio exceeds Feishu upload limit\") }","typeGuard":null,"tryCatchPattern":"if err := p.SendAudio(ctx, rc, audio, \"opus\"); err != nil {\n    if code, ok := feishuCodeFrom(err); ok {\n        switch code {\n        case 230013: /* file too large */ ...\n        default: slog.Error(\"feishu upload rejected\", \"code\", code)\n        }\n    }\n}","preventionTips":["Grant im:resource scope and republish the app","Validate file size/type against Feishu limits before upload","Confirm app installation in the target tenant","Track Feishu API changelog for constraint changes"],"tags":["feishu","upload","api-error","permissions"],"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"}