{"record":{"id":"7c83bb761ce676e3","repo":"ComposioHQ/composio","slug":"invalid-file-type","errorCode":null,"errorMessage":"Invalid file type","messagePattern":"Invalid file type","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"ts/packages/core/src/utils/fileUtils.node.ts","lineNumber":286,"sourceCode":"const readFile = async (\n  file: File | string,\n  signal?: AbortSignal\n): Promise<{ fileName: string; content: string; mimeType: string }> => {\n  if (file instanceof File) {\n    const content = await file.arrayBuffer();\n    return {\n      fileName: file.name,\n      content: uint8ArrayToBase64(new Uint8Array(content)),\n      mimeType: file.type,\n    };\n  } else if (typeof file === 'string') {\n    if (isHttpUrl(file)) {\n      return await readFileContentFromURL(file, signal);\n    } else {\n      return await readFileContent(file);\n    }\n  }\n  throw new Error('Invalid file type');\n};\n\nexport const getFileDataAfterUploadingToS3 = async (\n  file: File | string,\n  {\n    toolSlug,\n    toolkitSlug,\n    client,\n    sensitiveFileUploadProtection,\n    fileUploadPathDenySegments,\n    fileUploadAllowlist,\n    signal,\n  }: GetFileDataAfterUploadingToS3Options\n): Promise<FileUploadData> => {\n  if (!file) {\n    throw new Error('Either path or blob must be provided');\n  }\n","sourceCodeStart":268,"sourceCodeEnd":304,"githubUrl":"https://github.com/ComposioHQ/composio/blob/64b1b85502b1beeb2379e6c9e8bf1104504fa637/ts/packages/core/src/utils/fileUtils.node.ts#L268-L304","documentation":"readFile dispatches on input type: File objects, http(s) URLs, and local paths are supported. Anything else falls through to throw 'Invalid file type'.","triggerScenarios":"Passing a Blob (not File), a plain object, a number, or a non-http protocol string (ftp://, file://) to readFile/getFileDataAfterUploadingToS3.","commonSituations":"Cross-SDK porting where Python accepted plain blobs, or passing Buffer/Uint8Array directly instead of wrapping in a File.","solutions":["Wrap binary data in a File (new File([buffer], name)).","Use an http(s) URL or local filesystem path string.","Narrow the input type before calling: typeof file === 'string' || file instanceof File."],"exampleFix":"// before\nawait readFile(new Blob([bytes]));\n// after\nawait readFile(new File([bytes], 'data.bin'));","handlingStrategy":"type-guard","validationCode":"const isFileInput = (f: unknown): f is File | string =>\n  typeof f === 'string' || (typeof File !== 'undefined' && f instanceof File);","typeGuard":"const isFileInput = (f: unknown): f is File | string =>\n  typeof f === 'string' || f instanceof File;","tryCatchPattern":null,"preventionTips":["Wrap raw bytes in new File([bytes], name).","Use http(s):// URLs for remote files."],"tags":["validation","file-upload","typescript"],"backgroundTag":"invalid-argument-type","analyzedSha":"64b1b85502b1beeb2379e6c9e8bf1104504fa637","analyzedAt":"2026-08-28T15:39:33.623Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}