{"record":{"id":"0ae60b81f229cc3c","repo":"remotion-dev/remotion","slug":"could-not-parse-window-remotion-publicpath-in-th","errorCode":null,"errorMessage":"Could not parse `window.remotion_publicPath` in the bundle index.html.","messagePattern":"Could not parse `window\\.remotion_publicPath` in the bundle index\\.html\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/lambda/src/shared/validate-bundle-dir.ts","lineNumber":16,"sourceCode":"import fs from 'node:fs';\nimport path from 'node:path';\n\nconst getPublicPath = (indexHtml: string): unknown => {\n\tconst match = indexHtml.match(\n\t\t/window\\.remotion_publicPath\\s*=\\s*(\"(?:[^\"\\\\]|\\\\.)*\")\\s*;/,\n\t);\n\n\tif (!match) {\n\t\treturn null;\n\t}\n\n\ttry {\n\t\treturn JSON.parse(match[1]);\n\t} catch (error) {\n\t\tthrow new Error(\n\t\t\t'Could not parse `window.remotion_publicPath` in the bundle index.html.',\n\t\t\t{cause: error},\n\t\t);\n\t}\n};\n\nconst validateNoDirectorySymlinks = (\n\tdirectory: string,\n\tbundleDir: string,\n): void => {\n\tfor (const entry of fs.readdirSync(directory, {withFileTypes: true})) {\n\t\tconst entryPath = path.join(directory, entry.name);\n\t\tif (entry.isSymbolicLink()) {\n\t\t\tif (fs.statSync(entryPath).isDirectory()) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`The bundle directory ${bundleDir} contains a symbolic link to a directory at ${path.relative(bundleDir, entryPath)}. Directory symbolic links are not supported by \\`deploySiteFromBundle()\\`.`,\n\t\t\t\t);\n\t\t\t}","sourceCodeStart":1,"sourceCodeEnd":34,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/lambda/src/shared/validate-bundle-dir.ts#L1-L34","documentation":"Thrown by getPublicPath() inside validateBundleDir() when the regex matched a `window.remotion_publicPath = \"...\";` assignment in index.html but the captured string could not be JSON.parsed. This means the bundle's index.html is syntactically malformed at that specific line.","triggerScenarios":"Bundling produced an index.html whose remotion_publicPath line has an unescaped quote, truncated string, or other JSON-invalid content; manually editing index.html after bundling; filesystem corruption or partial write of the bundle.","commonSituations":"Hand-editing the bundle output; a custom bundling pipeline that rewrites index.html; transferring the bundle through a tool that mangled quotes; partial/aborted bundle write.","solutions":["Re-run the bundle step cleanly (`npx remotion bundle`) and do not hand-edit index.html.","Inspect index.html for the remotion_publicPath line and confirm the value is a properly JSON-quoted string ending in a semicolon.","If using a custom bundling wrapper, ensure it does not rewrite or escape that line."],"exampleFix":"// no code-level fix; rebuild the bundle:\n// $ npx remotion bundle --props=... entry.ts","handlingStrategy":"validation","validationCode":"import fs from 'node:fs'\nfunction assertPublicPathParses(bundleDir) {\n  const html = fs.readFileSync(`${bundleDir}/index.html`, 'utf8')\n  const m = html.match(/window\\.remotion_publicPath\\s*=\\s*(\"(?:[^\"\\\\]|\\\\.)*\")\\s*;/)\n  if (m) JSON.parse(m[1]) // throws if malformed\n}","typeGuard":null,"tryCatchPattern":"try {\n  await deploySiteFromBundle({bucketName, region, bundleDir})\n} catch (e) {\n  if (/Could not parse `window.remotion_publicPath`/.test(e.message)) {\n    // rebuild the bundle and retry\n  } else throw e\n}","preventionTips":["Never hand-edit index.html in a Remotion bundle.","Regenerate bundles with `npx remotion bundle` instead of patching them.","Treat bundles as opaque build artifacts."],"tags":["bundling","validation","filesystem"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}