Skip to content

Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.

fix(core): drop manual Content-Length in S3 upload PUT for compat with strict undici dispatcher (refs #3548) (#3549)

komaifd88b2e5b7e8
diff --git a/ts/packages/core/src/utils/fileUtils.node.ts b/ts/packages/core/src/utils/fileUtils.node.ts
index 05ac20b27..57b04341b 100644
--- a/ts/packages/core/src/utils/fileUtils.node.ts
+++ b/ts/packages/core/src/utils/fileUtils.node.ts
@@ -209,12 +209,16 @@ const uploadFileToS3 = async (
const uploadBuffer = new Uint8Array(contentBytes.byteLength);
uploadBuffer.set(contentBytes);
+ // Note: do not set `Content-Length` manually. Node.js's built-in fetch (undici)
+ // computes it from `body` and rejects any user-supplied value with
+ // `InvalidArgumentError: invalid content-length header`, which surfaces as
+ // `TypeError: fetch failed` and breaks every `file_uploadable` connector tool
+ // on Node 22+.
const uploadResponse = await fetch(signedURL, {
method: 'PUT',
body: uploadBuffer,
headers: {
'Content-Type': mimeType,
- 'Content-Length': contentBytes.length.toString(),
},
});