ComposioHQ/composio · error · ValidationError
Failed to parse tool router session files mount upload optio
Error message
Failed to parse tool router session files mount upload options
What it means
The upload() method on a tool router session file mount validates its options argument with ToolRouterSessionFilesMountUploadOptionsSchema before doing any work. If the options object does not match the expected schema (e.g. mountId is missing or not a string), a Zod ValidationError wrapping the parse issues is thrown. The library does this to fail fast before attempting any network upload.
Source
Thrown at ts/packages/core/src/models/ToolRouterSessionFileMount.ts:219
* ```typescript
* // From native File (e.g. from input[type=file])
* await session.experimental.files.upload(fileInput.files[0]);
* ```
*
* @example
* ```typescript
* // From raw buffer
* await session.experimental.files.upload(buffer, { remotePath: 'data.json', mimetype: 'application/json' });
* ```
*/
async upload(
input: string | File | ArrayBuffer | Uint8Array,
options?: ToolRouterSessionFilesMountUploadOptions
): Promise<RemoteFile> {
const uploadOptions = ToolRouterSessionFilesMountUploadOptionsSchema.safeParse(options ?? {});
if (!uploadOptions.success) {
throw new ValidationError('Failed to parse tool router session files mount upload options', {
cause: uploadOptions.error,
});
}
const { fileToUpload, remotePath, mimetype } = await this.normalizeUploadInput(
input,
uploadOptions.data
);
const createUploadURLResponse = await this.client.toolRouter.session.files.createUploadURL(
uploadOptions.data.mountId,
{
session_id: this.sessionId,
mount_relative_path: remotePath,
mimetype,
}
);
View on GitHub (pinned to 64b1b85502)
Solutions
- Pass a valid mountId string in the upload options: upload(file, { mountId: '<mount-id>' })
- Check that the mount exists and capture its id from the session file mount creation response before uploading
- Inspect error.cause (a ZodError) to see exactly which field failed validation
Example fix
// before
await mount.upload(file, { moutnId: mountId });
// after
await mount.upload(file, { mountId: mountId }); Defensive patterns
Strategy: validation
Validate before calling
import { ToolRouterSessionFilesMountUploadOptionsSchema } from '@composio/core';
const check = ToolRouterSessionFilesMountUploadOptionsSchema.safeParse({ mountId });
if (!check.success) throw new Error(check.error.issues.map(i => i.path.join('.')).join(', '));
await mount.upload(file, check.data); Type guard
const hasMountId = (o: unknown): o is { mountId: string } =>
typeof o === 'object' && o !== null &&
typeof (o as { mountId?: unknown }).mountId === 'string' &&
(o as { mountId: string }).mountId.length > 0; Try / catch
try { await mount.upload(file, opts); } catch (e) { if (e instanceof ValidationError) { console.error(e.cause?.issues); } throw e; } Prevention
- Always create/lookup the mount first and pass its exact id
- Type the options parameter explicitly as ToolRouterSessionFilesMountUploadOptions
When it happens
Trigger: Calling toolRouterSession.files.upload(input, { mountId: ... }) (or the files-mount upload API) with an options object where mountId is missing, undefined, or not a valid string; passing extra invalid fields also fails if the schema is strict.
Common situations: Forgetting to pass mountId when uploading to a session file mount, passing a numeric or object mount id, or constructing options dynamically where a key is typo'd or undefined.
Understand the failure class
Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
Related errors
- Failed to parse remote file properties
- Failed to parse tool router session files mount download opt
- Failed to parse tool router session files mount delete optio
- Invalid arguments for local tool ${resolution.finalSlug}: ${
- Failed to parse create connected account link options
AI-assisted analysis of ComposioHQ/composio@64b1b85502 (2026-08-28).
Data as JSON: /api/errors/b2f9cc9f7d8f2035.
Report an issue: GitHub.