ComposioHQ/composio · warning · ComposioFileUploadAbortedError
File upload was aborted because beforeFileUpload returned fa
Error message
File upload was aborted because beforeFileUpload returned false.
What it means
runBeforeFileUpload invokes the user-supplied beforeFileUpload hook; when the hook returns false, the SDK aborts the upload with ComposioFileUploadAbortedError. This is a deliberate, policy-driven abort for local paths/URLs.
Source
Thrown at ts/packages/core/src/utils/modifiers/FileToolModifier.node.ts:91
if (isEmptyFileValue(value)) return DELETE_VALUE;
// Upload only if the runtime value is a string (i.e., a local path) or blob
if (typeof value !== 'string' && !(value instanceof File)) return value;
const runBeforeFileUpload = async (
path: string,
source: 'path' | 'url' | 'file'
): Promise<string> => {
if (!ctx.beforeFileUpload) {
return path;
}
const out = await ctx.beforeFileUpload({
path,
source,
toolSlug: ctx.toolSlug,
toolkitSlug: ctx.toolkitSlug,
});
if (out === false) {
throw new ComposioFileUploadAbortedError(
'File upload was aborted because beforeFileUpload returned false.'
);
}
return out;
};
if (typeof value === 'string') {
// Match the URL/local-path split used downstream in
// getFileDataAfterUploadingToS3 so the hook sees the same categorisation.
const source = isHttpUrl(value) ? 'url' : 'path';
const pathOrUrl = await runBeforeFileUpload(value, source);
logger.debug(`Uploading file "${pathOrUrl}"`);
return getFileDataAfterUploadingToS3(pathOrUrl, {
toolSlug: ctx.toolSlug,
toolkitSlug: ctx.toolkitSlug,
client: ctx.client,
sensitiveFileUploadProtection: ctx.sensitiveFileUploadProtection,
fileUploadPathDenySegments: ctx.fileUploadPathDenySegments,View on GitHub (pinned to 64b1b85502)
Solutions
- This is expected behavior: catch ComposioFileUploadAbortedError and handle the rejection gracefully.
- Adjust the hook's condition if legitimate files are being rejected.
- Log path/source in the hook to see why it returned false.
Example fix
// before
beforeFileUpload: ({ path }) => path.startsWith('/data'),
// after
beforeFileUpload: ({ path }) => path.startsWith('/data') || path.startsWith('/tmp/uploads'), Defensive patterns
Strategy: try-catch
Type guard
const isUploadAborted = (e: unknown): e is ComposioFileUploadAbortedError => e instanceof ComposioFileUploadAbortedError;
Try / catch
try { await tool.execute(args); }
catch (e) { if (isUploadAborted(e)) { /* policy rejection, skip */ return; } throw e; } Prevention
- Make beforeFileUpload conditions explicit and logged.
- Return true for allowed files; return false only for intentional blocks.
When it happens
Trigger: Configuring a FileToolModifier with beforeFileUpload that returns false for a given path/url (e.g. allowlist mismatch, size check failed) and then executing the tool with that path.
Common situations: Allowlisting specific directories, blocking file types, or content checks in the hook — the throw is your own policy firing, not a bug.
Related errors
- Failed to fetch file: ${response.statusText}
- Invalid file type
- Either path or blob must be provided
- maxBytes must be a non-negative safe integer
- File upload was aborted because before_file_upload returned
AI-assisted analysis of ComposioHQ/composio@64b1b85502 (2026-08-28).
Data as JSON: /api/errors/c5ba371ae7f95dfc.
Report an issue: GitHub.