{"record":{"id":"1ad272236a5f8f52","repo":"ComposioHQ/composio","slug":"file-system-operations-are-not-supported-in-this-r-1ad272","errorCode":null,"errorMessage":"File system operations are not supported in this runtime environment","messagePattern":"File system operations are not supported in this runtime environment","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"ts/packages/core/src/utils/fileUtils.node.ts","lineNumber":154,"sourceCode":"\n    return cleanSubtype || 'txt';\n  }\n\n  return 'txt'; // Default fallback\n};\n\n// Helper function to generate a filename with timestamp and random ID\nconst generateTimestampedFilename = (extension: string, prefix?: string): string => {\n  const basePrefix = prefix || 'file_ts';\n  return `${basePrefix}${Date.now()}${getRandomShortId()}.${extension}`;\n};\n\nconst readFileContent = async (\n  filePath: string\n): Promise<{ fileName: string; content: string; mimeType: string }> => {\n  try {\n    if (!platform.supportsFileSystem) {\n      throw new Error('File system operations are not supported in this runtime environment');\n    }\n    const content = platform.readFileSync(filePath);\n    return {\n      fileName: generateTimestampedFilename(filePath.split('.').pop() || 'txt'),\n      content:\n        content instanceof Uint8Array\n          ? uint8ArrayToBase64(content)\n          : uint8ArrayToBase64(new TextEncoder().encode(content)),\n      mimeType: 'application/octet-stream',\n    };\n  } catch (error) {\n    throw new Error(`Error reading file at ${filePath}: ${error}`);\n  }\n};\n\nconst readFileContentFromURL = async (\n  path: string,\n  signal?: AbortSignal","sourceCodeStart":136,"sourceCodeEnd":172,"githubUrl":"https://github.com/ComposioHQ/composio/blob/64b1b85502b1beeb2379e6c9e8bf1104504fa637/ts/packages/core/src/utils/fileUtils.node.ts#L136-L172","documentation":"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.","triggerScenarios":"Calling readFile/getFileDataAfterUploadingToS3 with a local file path string in an environment where the platform adapter reports no file system support.","commonSituations":"Running SDK code bundled for browsers, workers, or edge runtimes while passing local paths instead of File objects or URLs.","solutions":["Pass a File/Blob object instead of a local path in browser environments.","Use an https:// URL so readFileContentFromURL is used instead.","Run in a Node environment where the file-system platform adapter is registered."],"exampleFix":"// before\nawait getFileDataAfterUploadingToS3('/tmp/report.pdf', {...});\n// after\nawait getFileDataAfterUploadingToS3(new File([bytes], 'report.pdf'), {...});","handlingStrategy":"type-guard","validationCode":"import { platform } from './platform';\nif (!platform.supportsFileSystem) throw new Error('Use File/URL inputs in this runtime');","typeGuard":"const supportsFs = (): boolean => platform.supportsFileSystem === true;","tryCatchPattern":null,"preventionTips":["Pass File objects or URLs in browser/edge builds.","Gate file-path code paths on runtime detection (typeof window, process.versions?.node)."],"tags":["runtime","filesystem","browser","typescript"],"backgroundTag":"unsupported-platform-operation","analyzedSha":"64b1b85502b1beeb2379e6c9e8bf1104504fa637","analyzedAt":"2026-08-28T15:39:33.623Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}