{"record":{"id":"7a9447acb262ac67","repo":"ComposioHQ/composio","slug":"failed-to-parse-remote-file-response","errorCode":null,"errorMessage":"Failed to parse remote file response","messagePattern":"Failed to parse remote file response","errorType":"validation","errorClass":"ValidationError","httpStatus":null,"severity":"error","filePath":"ts/packages/core/src/models/RemoteFile.ts","lineNumber":68,"sourceCode":"  readonly downloadUrl: string;\n\n  constructor(data: RemoteFileData) {\n    this.expiresAt = data.expiresAt;\n    this.mountRelativePath = data.mountRelativePath;\n    this.sandboxMountPrefix = data.sandboxMountPrefix;\n    this.downloadUrl = data.downloadUrl;\n  }\n\n  /**\n   * Parses an API response (snake_case) and returns a RemoteFile instance.\n   * @param data - Raw API response with snake_case keys\n   * @returns A RemoteFile instance\n   * @throws ValidationError if the response shape is invalid\n   */\n  static parse(data: unknown): RemoteFile {\n    const parsed = RemoteFileDataSchema.safeParse(data);\n    if (!parsed.success) {\n      throw new ValidationError('Failed to parse remote file response', {\n        cause: parsed.error,\n      });\n    }\n    return new RemoteFile(parsed.data);\n  }\n\n  /** Filename extracted from the mount path (e.g. \"report.pdf\" from \"output/report.pdf\") */\n  get filename(): string {\n    return platform.basename(this.mountRelativePath);\n  }\n\n  /**\n   * Fetches the file content as a buffer.\n   * @returns The file content as a Uint8Array\n   * @throws RemoteFileDownloadError if the fetch fails\n   */\n  async buffer(): Promise<Uint8Array> {\n    // SSRF guard: `downloadUrl` is set from an API response, so it is untrusted","sourceCodeStart":50,"sourceCodeEnd":86,"githubUrl":"https://github.com/ComposioHQ/composio/blob/64b1b85502b1beeb2379e6c9e8bf1104504fa637/ts/packages/core/src/models/RemoteFile.ts#L50-L86","documentation":"RemoteFile.parse() received data that does not conform to RemoteFileDataSchema. The SDK validates every remote-file payload from the API before constructing a RemoteFile, throwing ValidationError with the Zod issues as cause.","triggerScenarios":"Passing a hand-crafted or modified object to RemoteFile.parse, or a backend response whose file fields (downloadUrl, filename, mountRelativePath, etc.) are missing or mistyped.","commonSituations":"Mocking API responses in tests with incomplete fixtures; API changes renaming file fields; serializing/deserializing a RemoteFile and feeding the altered shape back into parse().","solutions":["Check error.cause to identify missing/invalid fields","Fix the payload to include all required RemoteFileData fields with correct types","In tests, base mocks on a captured real response"],"exampleFix":"// before\nconst f = RemoteFile.parse({ id: 'f1' });\n// after\nconst f = RemoteFile.parse({ id: 'f1', downloadUrl: 'https://...', filename: 'a.pdf', mountRelativePath: '/a.pdf' });","handlingStrategy":"type-guard","validationCode":"import { RemoteFileDataSchema } from '@composio/core';\nconst r = RemoteFileDataSchema.safeParse(data);\nif (!r.success) throw new Error(JSON.stringify(r.error.issues));\nconst f = RemoteFile.parse(data);","typeGuard":"const isRemoteFileData = (d: unknown): boolean => RemoteFileDataSchema.safeParse(d).success;","tryCatchPattern":"try { RemoteFile.parse(data); } catch (e) { if (e instanceof ValidationError && /remote file/.test(e.message)) { logIssues(e.cause); return null; } throw e; }","preventionTips":["Base test fixtures on captured real responses","Don't round-trip RemoteFile objects through JSON into parse()","Validate unknown payloads with the exported schema first"],"tags":["files","zod","validation","response-parsing"],"backgroundTag":"schema-validation-failed","analyzedSha":"64b1b85502b1beeb2379e6c9e8bf1104504fa637","analyzedAt":"2026-08-28T15:39:33.623Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}