{"record":{"id":"13e21439fb34684a","repo":"CherryHQ/cherry-studio","slug":"feishu-rejected-the-file-upload-for-file-filena","errorCode":null,"errorMessage":"Feishu rejected the file upload for \"${file.filename}\" (no file_key) — likely over Feishu's file size limit (~30MB) or the bot lacks file-send capability","messagePattern":"Feishu rejected the file upload for \"(.+?)\" \\(no file_key\\) — likely over Feishu's file size limit \\(~30MB\\) or the bot lacks file-send capability","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/main/ai/channels/adapters/feishu/FeishuAdapter.ts","lineNumber":598,"sourceCode":"          `Feishu rejected the image upload for \"${file.filename}\" (no image_key) — likely over Feishu's image size limit (~10MB) or the bot lacks image-send capability`\n        )\n      }\n\n      ensureFeishuSuccess(\n        await this.client.im.message.create({\n          params: { receive_id_type: 'chat_id' },\n          data: { receive_id: chatId, msg_type: 'image', content: JSON.stringify({ image_key: imageKey }) }\n        }),\n        'Send Feishu image'\n      )\n    } else {\n      const uploaded = await this.client.im.file.create({\n        data: { file_type: 'stream', file_name: file.filename, file: buffer }\n      })\n      const fileKey = uploaded?.file_key\n      if (!fileKey) {\n        this.log.warn('Feishu file upload returned no file_key', { chatId, filename: file.filename, size: file.size })\n        throw new Error(\n          `Feishu rejected the file upload for \"${file.filename}\" (no file_key) — likely over Feishu's file size limit (~30MB) or the bot lacks file-send capability`\n        )\n      }\n\n      ensureFeishuSuccess(\n        await this.client.im.message.create({\n          params: { receive_id_type: 'chat_id' },\n          data: { receive_id: chatId, msg_type: 'file', content: JSON.stringify({ file_key: fileKey }) }\n        }),\n        'Send Feishu file'\n      )\n    }\n\n    this.log.info('Sent file', { chatId, filename: file.filename, size: file.size, mediaType: file.media_type })\n  }\n\n  async sendTypingIndicator(chatId: string): Promise<void> {\n    await this.setChatReaction(chatId, REACTION_THINKING)","sourceCodeStart":580,"sourceCodeEnd":616,"githubUrl":"https://github.com/CherryHQ/cherry-studio/blob/726446b54cd69ffe51a276638672f6d95ca0768c/src/main/ai/channels/adapters/feishu/FeishuAdapter.ts#L580-L616","documentation":"Companion to 105 for the generic-file branch: client.im.file.create with file_type 'stream' returns no file_key. Same unwrapped-data contract — a null file_key means the upload silently failed, so the adapter throws an enriched error instead of routing through ensureFeishuSuccess.","triggerScenarios":"Non-image file path: file.media_type does not start with 'image/', client.im.file.create resolves but uploaded.file_key is undefined/null/empty. Logged with chatId/filename/size, then thrown.","commonSituations":"File over Feishu's ~30MB file limit, bot lacking file-send capability, invalid file bytes, or filename containing characters the SDK rejects.","solutions":["Keep attachments under ~30MB; chunk or host large files externally and send a link instead.","Confirm the bot has file-send permission in the Feishu console.","Sanitize file.filename (ASCII-safe, no path separators) before upload.","Retry once on a null file_key for transient upload failures."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Validate size before upload.\nfunction isWithinFeishuFileLimit(file: FileAttachment): boolean {\n  const bytes = Math.ceil((file.data.length * 3) / 4)\n  return bytes <= 30 * 1024 * 1024\n}","typeGuard":"function isFeishuFileRejected(e: unknown): e is Error {\n  return e instanceof Error && e.message.startsWith('Feishu rejected the file upload')\n}","tryCatchPattern":"try {\n  await feishu.sendFile(chatId, file)\n} catch (e) {\n  if (isFeishuFileRejected(e)) {\n    await feishu.sendMessage(chatId, `[file too large to upload: ${file.filename}]`)\n    return\n  }\n  throw e\n}","preventionTips":["Keep attachments under 30MB; host larger files externally and send a link.","Confirm file-send permission in the Feishu console.","Sanitize filenames to ASCII-safe values before upload."],"tags":["feishu","file-upload","size-limit","permissions"],"backgroundTag":null,"analyzedSha":"726446b54cd69ffe51a276638672f6d95ca0768c","analyzedAt":"2026-08-12T17:30:37.448Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}