chenhg5/cc-connect · error
%s: upload video: %w
Error message
%s: upload video: %w
What it means
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.
Source
Thrown at platform/feishu/feishu.go:5567
} else {
fileName = "video.mp4"
}
}
var uploadResp *larkim.CreateFileResp
if err := p.withTransientRetry(ctx, "upload video", func() error {
return p.withFreshTenantAccessTokenRetry(ctx, "upload video", func(client *lark.Client, options ...larkcore.RequestOptionFunc) error {
req := larkim.NewCreateFileReqBuilder().
Body(larkim.NewCreateFileReqBodyBuilder().
FileType(larkim.FileTypeMp4).
FileName(fileName).
File(bytes.NewReader(video)).
Build()).
Build()
var err error
uploadResp, err = client.Im.File.Create(ctx, req, options...)
if err != nil {
return fmt.Errorf("%s: upload video: %w", p.tag(), err)
}
if !uploadResp.Success() {
return fmt.Errorf("%s: upload video code=%d msg=%s", p.tag(), uploadResp.Code, uploadResp.Msg)
}
return nil
})
}); err != nil {
return err
}
if uploadResp.Data == nil || uploadResp.Data.FileKey == nil {
return fmt.Errorf("%s: upload video: no file_key returned", p.tag())
}
fileKey := *uploadResp.Data.FileKey
slog.Debug(p.tag()+": video uploaded", "file_key", fileKey, "format", format, "size", len(video))
mediaMsg := larkim.MessageMedia{FileKey: fileKey}
mediaContent, err := mediaMsg.String()View on GitHub (pinned to 4000b2338a)
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
Example fix
// before uploadResp, err = client.Im.File.Create(ctx, req, options...) // after — add timeout/retry at call site ctx, cancel := context.WithTimeout(ctx, 5*time.Minute) defer cancel() uploadResp, err = client.Im.File.Create(ctx, req, options...)
Defensive patterns
Strategy: try-catch
Validate before calling
if video == nil || len(video) == 0 { return errors.New("empty video payload") } Try / catch
if err := sendVideo(ctx, video); err != nil {
var fe *FeishuUploadError
if errors.As(err, &fe) { /* inspect wrapped cause */ }
slog.Error("video send failed", "err", err)
} Prevention
- Keep Feishu app credentials rotated and valid
- Set generous timeouts for large media uploads
- Monitor network egress to open.feishu.cn
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: "API request failed": what wrapped HTTP errors from external APIs mean and how to find the real cause — this error's family across 29 libraries.
Related errors
- %s: upload image: %w
- %s: upload file: %w
- %s: upload audio: %w
- redirected to unsupported image URL
- remote image host resolved to no usable IPs
AI-assisted analysis of chenhg5/cc-connect@4000b2338a (2026-09-06).
Data as JSON: /api/errors/0831590c7ee2eb29.
Report an issue: GitHub.