{"record":{"id":"dd1f0a0db248714b","repo":"remotion-dev/remotion","slug":"undefined-was-passed-to-staticfile","errorCode":null,"errorMessage":"undefined was passed to staticFile()","messagePattern":"undefined was passed to staticFile\\(\\)","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"packages/core/src/static-file.ts","lineNumber":97,"sourceCode":"\n\tconst encodedArray = splitBySlash.map((element) => {\n\t\treturn encodeURIComponent(element);\n\t});\n\tconst merged = encodedArray.join('/');\n\treturn merged;\n};\n\n/*\n * @description Reference a file from the public/ folder. If the file does not appear in the autocomplete, type the path manually.\n * @see [Documentation](https://www.remotion.dev/docs/staticfile)\n */\nexport const staticFile = (path: string) => {\n\tif (path === null) {\n\t\tthrow new TypeError('null was passed to staticFile()');\n\t}\n\n\tif (typeof path === 'undefined') {\n\t\tthrow new TypeError('undefined was passed to staticFile()');\n\t}\n\n\tif (path.startsWith('http://') || path.startsWith('https://')) {\n\t\tthrow new TypeError(\n\t\t\t`staticFile() does not support remote URLs - got \"${path}\". Instead, pass the URL without wrapping it in staticFile(). See: https://remotion.dev/docs/staticfile-remote-urls`,\n\t\t);\n\t}\n\n\tif (path.startsWith('..') || path.startsWith('./')) {\n\t\tthrow new TypeError(\n\t\t\t`staticFile() does not support relative paths - got \"${path}\". Instead, pass the name of a file that is inside the public/ folder. See: https://remotion.dev/docs/staticfile-relative-paths`,\n\t\t);\n\t}\n\n\tif (\n\t\tpath.startsWith('/Users') ||\n\t\tpath.startsWith('/home') ||\n\t\tpath.startsWith('/tmp') ||","sourceCodeStart":79,"sourceCodeEnd":115,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/core/src/static-file.ts#L79-L115","documentation":"staticFile() expects a string path to a file in the public/ folder. This guard catches an `undefined` argument, which is the most common mistake when a variable, prop, or config field is not set. The runtime guard exists because undefined reaches the call site through optional fields, missing imports, or untyped data even though the parameter is typed as string.","triggerScenarios":"Calling `staticFile(undefined)`, passing an object property that was never set (e.g. `staticFile(props.src)` when `src` is optional and omitted), or referencing a missing named export.","commonSituations":"Optional props that default to undefined; destructuring with a typo in the key name; data-driven renders where the asset path field is absent in some records.","solutions":["Provide a default string, e.g. `staticFile(props.src ?? 'fallback.png')`.","Add a runtime check that the path is a non-empty string before calling staticFile().","Fix the upstream source of the undefined value (missing import, wrong key, unset field)."],"exampleFix":"// before\nconst src = staticFile(props.backgroundUrl);\n\n// after\nif (!props.backgroundUrl) {\n  throw new Error('backgroundUrl is required');\n}\nconst src = staticFile(props.backgroundUrl);","handlingStrategy":"validation","validationCode":"const resolveAsset = (path: string | undefined, fallback?: string) => {\n  if (path === undefined) {\n    if (fallback) return staticFile(fallback);\n    throw new Error('asset path is undefined');\n  }\n  return staticFile(path);\n};","typeGuard":"const isDefinedString = (v: unknown): v is string =>\n  typeof v === 'string';","tryCatchPattern":null,"preventionTips":["Mark required asset props as `string` (not optional) in your component TypeScript types.","Default optional asset props with `?? 'fallback.png'`.","Add a build-time check that all composition props reference existing assets."],"tags":["staticfile","assets","undefined","validation","type-safety"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}