{"record":{"id":"b2f9cc9f7d8f2035","repo":"ComposioHQ/composio","slug":"failed-to-parse-tool-router-session-files-mount-up","errorCode":null,"errorMessage":"Failed to parse tool router session files mount upload options","messagePattern":"Failed to parse tool router session files mount upload options","errorType":"validation","errorClass":"ValidationError","httpStatus":null,"severity":"error","filePath":"ts/packages/core/src/models/ToolRouterSessionFileMount.ts","lineNumber":219,"sourceCode":"   * ```typescript\n   * // From native File (e.g. from input[type=file])\n   * await session.experimental.files.upload(fileInput.files[0]);\n   * ```\n   *\n   * @example\n   * ```typescript\n   * // From raw buffer\n   * await session.experimental.files.upload(buffer, { remotePath: 'data.json', mimetype: 'application/json' });\n   * ```\n   */\n  async upload(\n    input: string | File | ArrayBuffer | Uint8Array,\n    options?: ToolRouterSessionFilesMountUploadOptions\n  ): Promise<RemoteFile> {\n    const uploadOptions = ToolRouterSessionFilesMountUploadOptionsSchema.safeParse(options ?? {});\n\n    if (!uploadOptions.success) {\n      throw new ValidationError('Failed to parse tool router session files mount upload options', {\n        cause: uploadOptions.error,\n      });\n    }\n\n    const { fileToUpload, remotePath, mimetype } = await this.normalizeUploadInput(\n      input,\n      uploadOptions.data\n    );\n\n    const createUploadURLResponse = await this.client.toolRouter.session.files.createUploadURL(\n      uploadOptions.data.mountId,\n      {\n        session_id: this.sessionId,\n        mount_relative_path: remotePath,\n        mimetype,\n      }\n    );\n","sourceCodeStart":201,"sourceCodeEnd":237,"githubUrl":"https://github.com/ComposioHQ/composio/blob/64b1b85502b1beeb2379e6c9e8bf1104504fa637/ts/packages/core/src/models/ToolRouterSessionFileMount.ts#L201-L237","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\nawait mount.upload(file, { moutnId: mountId });\n// after\nawait mount.upload(file, { mountId: mountId });","handlingStrategy":"validation","validationCode":"import { ToolRouterSessionFilesMountUploadOptionsSchema } from '@composio/core';\nconst check = ToolRouterSessionFilesMountUploadOptionsSchema.safeParse({ mountId });\nif (!check.success) throw new Error(check.error.issues.map(i => i.path.join('.')).join(', '));\nawait mount.upload(file, check.data);","typeGuard":"const hasMountId = (o: unknown): o is { mountId: string } =>\n  typeof o === 'object' && o !== null &&\n  typeof (o as { mountId?: unknown }).mountId === 'string' &&\n  (o as { mountId: string }).mountId.length > 0;","tryCatchPattern":"try { await mount.upload(file, opts); } catch (e) { if (e instanceof ValidationError) { console.error(e.cause?.issues); } throw e; }","preventionTips":["Always create/lookup the mount first and pass its exact id","Type the options parameter explicitly as ToolRouterSessionFilesMountUploadOptions"],"tags":["validation","zod","upload","file-mount","typescript"],"backgroundTag":"schema-validation-failed","analyzedSha":"64b1b85502b1beeb2379e6c9e8bf1104504fa637","analyzedAt":"2026-08-28T15:39:33.623Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}