{"record":{"id":"4db365d827047e92","repo":"remotion-dev/remotion","slug":"outputlocation-must-be-a-string-but-got-typeof-n","errorCode":null,"errorMessage":"outputLocation must be a string but got ${typeof newOutputLocation} (${JSON.stringify(newOutputLocation)})","messagePattern":"outputLocation must be a string but got (.+?) \\((.+?)\\)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/cli/src/config/output-location.ts","lineNumber":5,"sourceCode":"let currentOutputLocation: string | null = null;\n\nexport const setOutputLocation = (newOutputLocation: string) => {\n\tif (typeof newOutputLocation !== 'string') {\n\t\tthrow new Error(\n\t\t\t`outputLocation must be a string but got ${typeof newOutputLocation} (${JSON.stringify(\n\t\t\t\tnewOutputLocation,\n\t\t\t)})`,\n\t\t);\n\t}\n\n\tif (newOutputLocation.trim() === '') {\n\t\tthrow new Error(`outputLocation must not be an empty string`);\n\t}\n\n\tcurrentOutputLocation = newOutputLocation;\n};\n\nexport const getOutputLocation = () => currentOutputLocation;\n\nexport const resetOutputLocation = () => {\n\tcurrentOutputLocation = null;\n};","sourceCodeStart":1,"sourceCodeEnd":23,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/cli/src/config/output-location.ts#L1-L23","documentation":"`Config.setOutputLocation()` validates that its argument is a string at runtime; any non-string throws an Error that echoes both the JS type and JSON representation of the value. The setter stores the final output path used by render/still when the user wants to override the CLI-supplied path.","triggerScenarios":"Calling `Config.setOutputLocation(undefined)`, `Config.setOutputLocation(123)`, `Config.setOutputLocation(null)`, or `Config.setOutputLocation({path: '...'})`.","commonSituations":"Reading a path from env (`process.env.OUT`) that may be undefined; passing a parsed JSON value that came back as a non-string; programmatically building the path with a helper that can return undefined.","solutions":["Make sure the value is always a string before calling: provide a fallback or assert the env var is set.","Coerce explicitly only if the input truly is string-like: `Config.setOutputLocation(String(value))`."],"exampleFix":"// before\nConfig.setOutputLocation(process.env.OUT);\n// after\nConfig.setOutputLocation(process.env.OUT ?? 'out/video.mp4');","handlingStrategy":"type-guard","validationCode":"const out = process.env.OUT;\nif (typeof out !== 'string') {\n  throw new Error(`OUT must be a string, got ${typeof out}`);\n}\nConfig.setOutputLocation(out);","typeGuard":"const isNonEmptyString = (v: unknown): v is string =>\n  typeof v === 'string' && v.trim().length > 0;","tryCatchPattern":null,"preventionTips":["Always provide a fallback path when sourcing from env.","Validate at the boundary where untyped data enters the program."],"tags":["config","validation","typescript","output"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}