chenhg5/cc-connect · error
%s: upload file: no file_key returned
Error message
%s: upload file: no file_key returned
What it means
The file upload reported success but uploadResp.Data or Data.FileKey is nil — the expected file_key is absent from an otherwise-successful response. Without file_key the library cannot build the file message, so it returns this explicit error.
Source
Thrown at platform/feishu/feishu.go:3346
FileName(fileName).
File(bytes.NewReader(file.Data)).
Build()).
Build()
var err error
uploadResp, err = client.Im.File.Create(ctx, req, options...)
if err != nil {
return fmt.Errorf("%s: upload file: %w", p.tag(), err)
}
if !uploadResp.Success() {
return fmt.Errorf("%s: upload file 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 file: no file_key returned", p.tag())
}
msgType := detectFeishuFileMessageType(fileType)
fileContent, err := buildFeishuFileMessageContent(msgType, *uploadResp.Data.FileKey)
if err != nil {
return fmt.Errorf("%s: build file message: %w", p.tag(), err)
}
return p.sendMediaMessage(ctx, rc, msgType, fileContent)
}
func (p *Platform) sendMediaMessage(ctx context.Context, rc replyContext, msgType, content string) error {
if p.shouldUseThreadOrReplyAPI(rc) {
return p.replyMessage(ctx, rc, msgType, content)
}
return p.createMessage(ctx, rc.chatID, msgType, content, "send media message")
}
View on GitHub (pinned to 4000b2338a)
Solutions
- Log the raw response including RequestId when this happens and compare with the SDK struct.
- Upgrade github.com/larksuite/oapi-sdk to the latest release.
- Retry the upload once; transient empty responses usually succeed on retry.
- Keep the existing nil guard so callers get this clear message rather than a nil dereference.
Defensive patterns
Strategy: type-guard
Validate before calling
if uploadResp == nil || uploadResp.Data == nil || uploadResp.Data.FileKey == nil {
return errors.New("feishu: file upload returned no file_key")
} Type guard
func hasFileKey(r *larkim.CreateFileResp) bool {
return r != nil && r.Data != nil && r.Data.FileKey != nil
} Try / catch
err := p.SendFile(ctx, rc, file)
if err != nil && strings.Contains(err.Error(), "no file_key returned") {
// retry upload once; escalate with RequestId if repeated
} Prevention
- Keep the SDK version current with Feishu's response schema.
- Always nil-check Data/FileKey before use.
- Capture RequestId in logs for Feishu support escalation.
When it happens
Trigger: After Im.File.Create succeeds (Success()==true), Data==nil or Data.FileKey==nil at platform/feishu/feishu.go:3346 — empty response body on HTTP 200, or SDK response struct mismatch.
Common situations: SDK version drift (field renamed/missing), Feishu incident returning empty bodies, response truncated by a middle proxy.
Understand the failure class
Background: "invalid response format", "malformed payload", "missing data field": when an API returns 200 but the response shape is wrong — this error's family across 23 libraries.
Related errors
- %s: upload image: no image_key returned
- incomplete onboarding response
- %s: upload image: %w
- %s: upload image code=%d msg=%s
- %s: upload file: %w
AI-assisted analysis of chenhg5/cc-connect@4000b2338a (2026-09-06).
Data as JSON: /api/errors/b79230c80c5ae7b2.
Report an issue: GitHub.