{"record":{"id":"51bd02003dc0aa36","repo":"remotion-dev/remotion","slug":"src-must-be-a-string-when-using-fetchreader","errorCode":null,"errorMessage":"src must be a string when using `fetchReader`","messagePattern":"src must be a string when using `fetchReader`","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/media-parser/src/readers/from-fetch.ts","lineNumber":244,"sourceCode":"\t\tLog.verbose(logLevel, `Reading from preload cache for ${key}`);\n\t\treturn cached;\n\t}\n\n\tLog.verbose(logLevel, `Fetching ${key}`);\n\tconst result = makeFetchRequest({range, src, controller});\n\tprefetchCache.set(key, result);\n\treturn result;\n};\n\nexport const fetchReadContent: ReadContent = async ({\n\tsrc,\n\trange,\n\tcontroller,\n\tlogLevel,\n\tprefetchCache,\n}) => {\n\tif (typeof src !== 'string' && src instanceof URL === false) {\n\t\tthrow new Error('src must be a string when using `fetchReader`');\n\t}\n\n\tconst fallbackName = src.toString().split('/').pop() as string;\n\n\tconst res = makeFetchRequestOrGetCached({\n\t\trange,\n\t\tsrc,\n\t\tcontroller,\n\t\tlogLevel,\n\t\tprefetchCache,\n\t});\n\n\tconst key = cacheKey({src, range});\n\tprefetchCache.delete(key);\n\n\tconst {\n\t\treader,\n\t\tcontentLength,","sourceCodeStart":226,"sourceCodeEnd":262,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/media-parser/src/readers/from-fetch.ts#L226-L262","documentation":"fetchReadContent (the reader's `read` entry) validates that src is a string or URL before proceeding; otherwise it throws. The fetch reader can only fetch over HTTP(S)/blob/data, so non-string/URL sources (e.g. a File, a Buffer, or a filesystem path) are rejected. This is the default reader when none is provided in the browser.","triggerScenarios":"Calling parseMedia without specifying reader, while passing a File, Blob, ArrayBuffer, or a raw filesystem path as src — i.e. relying on the default fetchReader for something it cannot fetch.","commonSituations":"Browser code passing a `File` from an <input type=file> but forgetting that fetchReader expects a URL; Node code passing a local path without setting `reader: nodeReader`; passing a Buffer/ReadableStream as src.","solutions":["For browser File/Blob, create an object URL first: `URL.createObjectURL(file)` and pass that string as src.","For Node filesystem paths, pass `reader: nodeReader` (from @remotion/media-parser/node-reader).","Ensure src is `string | URL` when using the default fetchReader.","Double-check you imported and set the reader if your src is not HTTP-addressable."],"exampleFix":"// before (browser File with default reader)\nawait parseMedia({src: userFile, fields: {durationInSeconds: true}}); // File\n\n// after\nconst url = URL.createObjectURL(userFile);\nawait parseMedia({src: url, fields: {durationInSeconds: true}});\nURL.revokeObjectURL(url);\n\n// (Node filesystem)\nimport {nodeReader} from '@remotion/media-parser/node-reader';\nawait parseMedia({src: '/data/video.mp4', reader: nodeReader, fields: {}});","handlingStrategy":"type-guard","validationCode":"// Normalize src before parse: object URL for File, nodeReader for FS\nfunction normalizeSrc(src: unknown, inNode: boolean) {\n  if (src instanceof File || src instanceof Blob) return URL.createObjectURL(src);\n  if (typeof src === 'string' || src instanceof URL) return src;\n  throw new Error('src must be string | URL | File');\n}","typeGuard":"const isFetchableSrc = (src: unknown): src is string | URL =>\n  typeof src === 'string' || src instanceof URL;","tryCatchPattern":"try {\n  await parseMedia({src, fields: {durationInSeconds: true}});\n} catch (e) {\n  if (e instanceof Error && e.message === 'src must be a string when using `fetchReader`') {\n    // src was a File/path: convert or switch reader\n    throw new Error('Pass an object URL (browser) or reader: nodeReader (node)');\n  }\n  throw e;\n}","preventionTips":["Convert File/Blob to object URLs before parsing in the browser.","Pass reader: nodeReader for filesystem paths in Node.","Type src as string | URL when using the default fetchReader.","Check src type at the boundary of your wrapper API."],"tags":["api-misuse","fetch-reader","src-type","media-parser"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}