{"record":{"id":"b0596ee5f27a3663","repo":"chenhg5/cc-connect","slug":"s-upload-video-code-d-msg-s","errorCode":null,"errorMessage":"%s: upload video code=%d msg=%s","messagePattern":"(.+?): upload video code=(.+?) msg=(.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"platform/feishu/feishu.go","lineNumber":5570,"sourceCode":"\t}\n\n\tvar uploadResp *larkim.CreateFileResp\n\tif err := p.withTransientRetry(ctx, \"upload video\", func() error {\n\t\treturn p.withFreshTenantAccessTokenRetry(ctx, \"upload video\", 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.FileTypeMp4).\n\t\t\t\t\tFileName(fileName).\n\t\t\t\t\tFile(bytes.NewReader(video)).\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 video: %w\", p.tag(), err)\n\t\t\t}\n\t\t\tif !uploadResp.Success() {\n\t\t\t\treturn fmt.Errorf(\"%s: upload video 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 video: no file_key returned\", p.tag())\n\t}\n\tfileKey := *uploadResp.Data.FileKey\n\n\tslog.Debug(p.tag()+\": video uploaded\", \"file_key\", fileKey, \"format\", format, \"size\", len(video))\n\n\tmediaMsg := larkim.MessageMedia{FileKey: fileKey}\n\tmediaContent, err := mediaMsg.String()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"%s: build video message: %w\", p.tag(), err)\n\t}","sourceCodeStart":5552,"sourceCodeEnd":5588,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/platform/feishu/feishu.go#L5552-L5588","documentation":"The Feishu file-upload API returned an HTTP 200 response but with a non-success business code (uploadResp.Success() false). The error surfaces the API code and msg so the developer can map it to Feishu's documented error-code table.","triggerScenarios":"client.Im.File.Create returns a response whose Success() is false during video upload — e.g. invalid file format, file exceeds size limits, missing scopes (im:resource), or app permission problems.","commonSituations":"App missing im:resource scope; video format not in allowed list (mp4 etc.); file larger than Feishu's 30MB limit for message files; bot not in the target chat causing permission codes.","solutions":["Read code=%d in the message and look it up in Feishu Open Platform error-code docs","Ensure the app has the im:resource (or im:file) permission scope approved and published","Verify the video format/extension is supported and within size limits","Re-upload after fixing; the error is deterministic for bad requests","Check that the tenant_access_token corresponds to the same app that owns the permissions"],"exampleFix":"// before: only err checked, non-success code not handled distinctly\nif err != nil { return ... }\n// after: also log code/msg upstream and alert on permission-class codes\nif !uploadResp.Success() {\n    slog.Error(\"feishu upload failed\", \"code\", uploadResp.Code, \"msg\", uploadResp.Msg)\n    return fmt.Errorf(\"%s: upload video code=%d msg=%s\", p.tag(), uploadResp.Code, uploadResp.Msg)\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"if err := sendVideo(...); err != nil {\n    if strings.Contains(err.Error(), \"code=\") {\n        // parse code and consult Feishu error-code table\n    }\n}","preventionTips":["Approve im:resource scope before enabling video sending","Validate video format/size against Feishu limits pre-upload","Keep the SDK version current"],"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-14T05:17:10.506Z"}