From 8fdb2e64a786e998b51fcce5da9b9802dde4cd0e Mon Sep 17 00:00:00 2001 From: Tak Hoffman <781889+Takhoffman@users.noreply.github.com> Date: Wed, 11 Feb 2026 22:31:24 -0600 Subject: [PATCH] fix: buffer upload path for feishu SDK (openclaw#10345) thanks @youngerstyle Co-authored-by: zhiyi <7426274+youngerstyle@users.noreply.github.com> Co-authored-by: Tak Hoffman <781889+Takhoffman@users.noreply.github.com> --- extensions/feishu/src/media.ts | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/extensions/feishu/src/media.ts b/extensions/feishu/src/media.ts index c1a32fed7d..c9e74fddf6 100644 --- a/extensions/feishu/src/media.ts +++ b/extensions/feishu/src/media.ts @@ -210,15 +210,16 @@ export async function uploadImageFeishu(params: { const client = createFeishuClient(account); - // SDK expects a Readable stream, not a Buffer - // Use type assertion since SDK actually accepts any Readable at runtime - const imageStream = typeof image === "string" ? fs.createReadStream(image) : Readable.from(image); + // SDK accepts Buffer directly or fs.ReadStream for file paths + // Using Readable.from(buffer) causes issues with form-data library + // See: https://github.com/larksuite/node-sdk/issues/121 + const imageData = typeof image === "string" ? fs.createReadStream(image) : image; const response = await client.im.image.create({ data: { image_type: imageType, - // eslint-disable-next-line @typescript-eslint/no-explicit-any -- SDK stream type - image: imageStream as any, + // eslint-disable-next-line @typescript-eslint/no-explicit-any -- SDK accepts Buffer or ReadStream + image: imageData as any, }, }); @@ -258,16 +259,17 @@ export async function uploadFileFeishu(params: { const client = createFeishuClient(account); - // SDK expects a Readable stream, not a Buffer - // Use type assertion since SDK actually accepts any Readable at runtime - const fileStream = typeof file === "string" ? fs.createReadStream(file) : Readable.from(file); + // SDK accepts Buffer directly or fs.ReadStream for file paths + // Using Readable.from(buffer) causes issues with form-data library + // See: https://github.com/larksuite/node-sdk/issues/121 + const fileData = typeof file === "string" ? fs.createReadStream(file) : file; const response = await client.im.file.create({ data: { file_type: fileType, file_name: fileName, - // eslint-disable-next-line @typescript-eslint/no-explicit-any -- SDK stream type - file: fileStream as any, + // eslint-disable-next-line @typescript-eslint/no-explicit-any -- SDK accepts Buffer or ReadStream + file: fileData as any, ...(duration !== undefined && { duration }), }, });