chenhg5/cc-connect · error

%s: upload video code=%d msg=%s

Error message

%s: upload video code=%d msg=%s

What it means

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.

Source

Thrown at platform/feishu/feishu.go:5570

	}

	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()
	if err != nil {
		return fmt.Errorf("%s: build video message: %w", p.tag(), err)
	}

View on GitHub (pinned to 4000b2338a)

Solutions

  1. Read code=%d in the message and look it up in Feishu Open Platform error-code docs
  2. Ensure the app has the im:resource (or im:file) permission scope approved and published
  3. Verify the video format/extension is supported and within size limits
  4. Re-upload after fixing; the error is deterministic for bad requests
  5. Check that the tenant_access_token corresponds to the same app that owns the permissions

Example fix

// before: only err checked, non-success code not handled distinctly
if err != nil { return ... }
// after: also log code/msg upstream and alert on permission-class codes
if !uploadResp.Success() {
    slog.Error("feishu upload failed", "code", uploadResp.Code, "msg", uploadResp.Msg)
    return fmt.Errorf("%s: upload video code=%d msg=%s", p.tag(), uploadResp.Code, uploadResp.Msg)
}
Defensive patterns

Strategy: try-catch

Try / catch

if err := sendVideo(...); err != nil {
    if strings.Contains(err.Error(), "code=") {
        // parse code and consult Feishu error-code table
    }
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of chenhg5/cc-connect@4000b2338a (2026-09-06). Data as JSON: /api/errors/b0596ee5f27a3663. Report an issue: GitHub.