ComposioHQ/composio · error · ValidationError

Failed to parse tool router session files mount delete optio

Error message

Failed to parse tool router session files mount delete options

What it means

The delete() method validates its options with ToolRouterSessionFilesMountDeleteOptionsSchema before calling the API. If the options object fails validation (typically a missing or invalid mountId), a ValidationError wrapping the Zod issues is thrown before any request is made.

Source

Thrown at ts/packages/core/src/models/ToolRouterSessionFileMount.ts:382

   *
   * @example
   * ```typescript
   * // Delete from a custom mount
   * await session.experimental.files.delete('/old-backup', {
   *   mountId: 'custom-mount',
   * });
   * ```
   *
   * @warning This operation is destructive. Deleted files cannot be recovered.
   */
  async delete(
    remotePath: string,
    options?: ToolRouterSessionFilesMountDeleteOptions
  ): Promise<FileDeleteResponse> {
    const deleteOptions = ToolRouterSessionFilesMountDeleteOptionsSchema.safeParse(options ?? {});

    if (!deleteOptions.success) {
      throw new ValidationError('Failed to parse tool router session files mount delete options', {
        cause: deleteOptions.error,
      });
    }

    const deleteResponse = await this.client.toolRouter.session.files.delete(
      deleteOptions.data.mountId,
      {
        session_id: this.sessionId,
        mount_relative_path: remotePath,
      }
    );
    const fileDeleteResponse = FileDeleteResponseSchema.safeParse(deleteResponse);
    if (!fileDeleteResponse.success) {
      throw new ValidationError('Failed to parse file delete response', {
        cause: fileDeleteResponse.error,
      });
    }
    return fileDeleteResponse.data;

View on GitHub (pinned to 64b1b85502)

Solutions

  1. Pass a valid mountId string in the delete options
  2. Reuse the same validated options object used for upload/download on the same mount
  3. Check error.cause issues for the precise failing field

Example fix

// before
await mount.delete('/data/file.csv', {});
// after
await mount.delete('/data/file.csv', { mountId });
Defensive patterns

Strategy: validation

Validate before calling

if (typeof opts?.mountId !== 'string' || !opts.mountId) throw new Error('mountId required');
await mount.delete(path, opts);

Type guard

const isDeleteOpts = (o: unknown): o is { mountId: string } =>
  typeof o === 'object' && o !== null && typeof (o as any).mountId === 'string';

Try / catch

try { await mount.delete(path, opts); } catch (e) { if (e instanceof ValidationError) console.error(e.cause?.issues); throw e; }

Prevention

When it happens

Trigger: Calling mount.delete(remotePath, options) where mountId is absent, undefined, or not a valid string.

Common situations: Calling delete right after upload without threading the mountId through, or a typo'd options key silently producing 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.

Related errors


AI-assisted analysis of ComposioHQ/composio@64b1b85502 (2026-08-28). Data as JSON: /api/errors/054022e6c97d2d4b. Report an issue: GitHub.