ComposioHQ/composio · error · Error

File system operations are not supported in this runtime env

Error message

File system operations are not supported in this runtime environment

What it means

readFileContent throws this when platform.supportsFileSystem is false, meaning the current runtime (e.g. browser or edge) cannot read files from disk. It guards the Node-only readFile path before attempting platform.readFileSync.

Source

Thrown at ts/packages/core/src/utils/fileUtils.node.ts:154

    return cleanSubtype || 'txt';
  }

  return 'txt'; // Default fallback
};

// Helper function to generate a filename with timestamp and random ID
const generateTimestampedFilename = (extension: string, prefix?: string): string => {
  const basePrefix = prefix || 'file_ts';
  return `${basePrefix}${Date.now()}${getRandomShortId()}.${extension}`;
};

const readFileContent = async (
  filePath: string
): Promise<{ fileName: string; content: string; mimeType: string }> => {
  try {
    if (!platform.supportsFileSystem) {
      throw new Error('File system operations are not supported in this runtime environment');
    }
    const content = platform.readFileSync(filePath);
    return {
      fileName: generateTimestampedFilename(filePath.split('.').pop() || 'txt'),
      content:
        content instanceof Uint8Array
          ? uint8ArrayToBase64(content)
          : uint8ArrayToBase64(new TextEncoder().encode(content)),
      mimeType: 'application/octet-stream',
    };
  } catch (error) {
    throw new Error(`Error reading file at ${filePath}: ${error}`);
  }
};

const readFileContentFromURL = async (
  path: string,
  signal?: AbortSignal

View on GitHub (pinned to 64b1b85502)

Solutions

  1. Pass a File/Blob object instead of a local path in browser environments.
  2. Use an https:// URL so readFileContentFromURL is used instead.
  3. Run in a Node environment where the file-system platform adapter is registered.

Example fix

// before
await getFileDataAfterUploadingToS3('/tmp/report.pdf', {...});
// after
await getFileDataAfterUploadingToS3(new File([bytes], 'report.pdf'), {...});
Defensive patterns

Strategy: type-guard

Validate before calling

import { platform } from './platform';
if (!platform.supportsFileSystem) throw new Error('Use File/URL inputs in this runtime');

Type guard

const supportsFs = (): boolean => platform.supportsFileSystem === true;

Prevention

When it happens

Trigger: Calling readFile/getFileDataAfterUploadingToS3 with a local file path string in an environment where the platform adapter reports no file system support.

Common situations: Running SDK code bundled for browsers, workers, or edge runtimes while passing local paths instead of File objects or URLs.

Related errors


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