{"record":{"id":"c87b9dfe3c29e43b","repo":"sipeed/picoclaw","slug":"feishu-file-upload-no-file-key-returned","errorCode":null,"errorMessage":"feishu file upload: no file_key returned","messagePattern":"feishu file upload: no file_key returned","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/channels/feishu/feishu_64.go","lineNumber":1212,"sourceCode":"\t// Upload file to get file_key\n\tuploadReq := larkim.NewCreateFileReqBuilder().\n\t\tBody(larkim.NewCreateFileReqBodyBuilder().\n\t\t\tFileType(feishuFileType).\n\t\t\tFileName(filename).\n\t\t\tFile(file).\n\t\t\tBuild()).\n\t\tBuild()\n\n\tuploadResp, err := c.client.Im.V1.File.Create(ctx, uploadReq)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"feishu file upload: %w\", err)\n\t}\n\tif !uploadResp.Success() {\n\t\tc.invalidateTokenOnAuthError(uploadResp.Code)\n\t\treturn fmt.Errorf(\"feishu file upload api error (code=%d msg=%s)\", uploadResp.Code, uploadResp.Msg)\n\t}\n\tif uploadResp.Data == nil || uploadResp.Data.FileKey == nil {\n\t\treturn fmt.Errorf(\"feishu file upload: no file_key returned\")\n\t}\n\n\tfileKey := *uploadResp.Data.FileKey\n\n\t// Send file message\n\tcontent, _ := json.Marshal(map[string]string{\"file_key\": fileKey})\n\treq := larkim.NewCreateMessageReqBuilder().\n\t\tReceiveIdType(larkim.CreateMessageV1ReceiveIDTypeChatId).\n\t\tBody(larkim.NewCreateMessageReqBodyBuilder().\n\t\t\tReceiveId(chatID).\n\t\t\tMsgType(larkim.MsgTypeFile).\n\t\t\tContent(string(content)).\n\t\t\tBuild()).\n\t\tBuild()\n\n\tresp, err := c.client.Im.V1.Message.Create(ctx, req)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"feishu file send: %w\", err)","sourceCodeStart":1194,"sourceCodeEnd":1230,"githubUrl":"https://github.com/sipeed/picoclaw/blob/49183d7e8daed0dba89ddbb6fcb60089401d9680/pkg/channels/feishu/feishu_64.go#L1194-L1230","documentation":"The file upload reported Success()==true but Data or Data.FileKey is nil — an unexpected payload where the API claims success yet returns no file_key. A protocol deviation (gateway quirk or SDK response-shape mismatch), not an input error; nothing in the request is wrong.","triggerScenarios":"Im.V1.File.Create succeeds with an empty data block; observed under Feishu gateway degradation or when the vendored lark SDK version parses the live response schema incorrectly.","commonSituations":"After an oapi-sdk-go version bump; during transient Feishu incidents; large-file edge cases hitting a partial gateway response.","solutions":["Retry the upload once — usually transient.","Pin or upgrade the lark oapi SDK to a version aligned with the current Feishu response schema.","Log the raw response body once to confirm data.file_key is truly absent (rules out SDK parsing).","If reproducible, report to Feishu open-platform support with the request ID."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":"func isMissingFileKey(err error) bool {\n    return strings.Contains(err.Error(), \"feishu file upload: no file_key returned\")\n}","tryCatchPattern":"if err := ch.SendMedia(ctx, msg); err != nil {\n    if isMissingFileKey(err) {\n        // retry the upload once; persistent recurrence points to SDK/API schema drift\n    }\n}","preventionTips":["Pin the lark oapi SDK version","Retry once on empty-payload responses","Capture raw upload responses during integration tests"],"tags":["feishu","upload","go","lark-sdk","unexpected-response"],"backgroundTag":null,"analyzedSha":"49183d7e8daed0dba89ddbb6fcb60089401d9680","analyzedAt":"2026-08-15T21:55:41.315Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}