{"record":{"id":"0831590c7ee2eb29","repo":"chenhg5/cc-connect","slug":"s-upload-video-w","errorCode":null,"errorMessage":"%s: upload video: %w","messagePattern":"(.+?): upload video: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"platform/feishu/feishu.go","lineNumber":5567,"sourceCode":"\t\t} else {\n\t\t\tfileName = \"video.mp4\"\n\t\t}\n\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()","sourceCodeStart":5549,"sourceCodeEnd":5585,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/platform/feishu/feishu.go#L5549-L5585","documentation":"This error wraps the underlying SDK/transport error returned by the Feishu Open Platform file-upload API (im/v1/files) when uploading a video file. The platform's SendVideo path builds a multipart upload request and calls client.Im.File.Create; any failure from that call (network, auth, API rejection) is wrapped with the platform tag so the caller can attribute it to the video-upload step.","triggerScenarios":"Sending a video message via the Feishu platform when the Im.File.Create upload call returns a Go error: network failure, expired/invalid tenant_access_token, request-context timeout, or SDK-level request build failure.","commonSituations":"Expired Feishu app credentials; sandbox network egress blocked; file upload endpoint rate-limited or temporary 5xx surfaced as transport error; ctx deadline exceeded on slow uplinks for large videos.","solutions":["Inspect the wrapped error (%w) for the root cause from the Feishu SDK and fix that underlying issue first","Verify app credentials (App ID/App Secret) are valid and the token refresh works","Check network egress to open.feishu.cn / open.larksuite.com from the host","Retry with a smaller video or longer context timeout; Feishu uploads can be slow","Enable debug logging of the upload response code to distinguish transport vs API errors"],"exampleFix":"// before\nuploadResp, err = client.Im.File.Create(ctx, req, options...)\n// after — add timeout/retry at call site\nctx, cancel := context.WithTimeout(ctx, 5*time.Minute)\ndefer cancel()\nuploadResp, err = client.Im.File.Create(ctx, req, options...)","handlingStrategy":"try-catch","validationCode":"if video == nil || len(video) == 0 { return errors.New(\"empty video payload\") }","typeGuard":null,"tryCatchPattern":"if err := sendVideo(ctx, video); err != nil {\n    var fe *FeishuUploadError\n    if errors.As(err, &fe) { /* inspect wrapped cause */ }\n    slog.Error(\"video send failed\", \"err\", err)\n}","preventionTips":["Keep Feishu app credentials rotated and valid","Set generous timeouts for large media uploads","Monitor network egress to open.feishu.cn"],"tags":["feishu","upload","video","network"],"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-14T00:17:10.932Z"}