ComposioHQ/composio · error · Error
Invalid file type
Error message
Invalid file type
What it means
readFile dispatches on input type: File objects, http(s) URLs, and local paths are supported. Anything else falls through to throw 'Invalid file type'.
Source
Thrown at ts/packages/core/src/utils/fileUtils.node.ts:286
const readFile = async (
file: File | string,
signal?: AbortSignal
): Promise<{ fileName: string; content: string; mimeType: string }> => {
if (file instanceof File) {
const content = await file.arrayBuffer();
return {
fileName: file.name,
content: uint8ArrayToBase64(new Uint8Array(content)),
mimeType: file.type,
};
} else if (typeof file === 'string') {
if (isHttpUrl(file)) {
return await readFileContentFromURL(file, signal);
} else {
return await readFileContent(file);
}
}
throw new Error('Invalid file type');
};
export const getFileDataAfterUploadingToS3 = async (
file: File | string,
{
toolSlug,
toolkitSlug,
client,
sensitiveFileUploadProtection,
fileUploadPathDenySegments,
fileUploadAllowlist,
signal,
}: GetFileDataAfterUploadingToS3Options
): Promise<FileUploadData> => {
if (!file) {
throw new Error('Either path or blob must be provided');
}
View on GitHub (pinned to 64b1b85502)
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.
Example fix
// before await readFile(new Blob([bytes])); // after await readFile(new File([bytes], 'data.bin'));
Defensive patterns
Strategy: type-guard
Validate before calling
const isFileInput = (f: unknown): f is File | string => typeof f === 'string' || (typeof File !== 'undefined' && f instanceof File);
Type guard
const isFileInput = (f: unknown): f is File | string => typeof f === 'string' || f instanceof File;
Prevention
- Wrap raw bytes in new File([bytes], name).
- Use http(s):// URLs for remote files.
When it happens
Trigger: Passing a Blob (not File), a plain object, a number, or a non-http protocol string (ftp://, file://) to readFile/getFileDataAfterUploadingToS3.
Common situations: Cross-SDK porting where Python accepted plain blobs, or passing Buffer/Uint8Array directly instead of wrapping in a File.
Understand the failure class
Background: Invalid argument type errors: "must be of type string", "expected X, got Y", and ERR_INVALID_ARG_TYPE explained — this error's family across 15 libraries.
Related errors
- Either path or blob must be provided
- maxBytes must be a non-negative safe integer
- experimental_subAgent() target must be "claude", "codex", or
- Unsupported upload source
- Invalid Composio CLI release tag: ${releaseTag}
AI-assisted analysis of ComposioHQ/composio@64b1b85502 (2026-08-28).
Data as JSON: /api/errors/7c83bb761ce676e3.
Report an issue: GitHub.