{"record":{"id":"de452170a7ab5f93","repo":"remotion-dev/remotion","slug":"the-name-prop-location-must-be-a-string-b","errorCode":null,"errorMessage":"The \"${name}\" prop ${location} must be a string, but you passed a value of type ${typeof defaultCodec}.","messagePattern":"The \"(.+?)\" prop (.+?) must be a string, but you passed a value of type (.+?)\\.","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"packages/core/src/validation/validate-default-codec.ts","lineNumber":14,"sourceCode":"import type {Codec, CodecOrUndefined} from '../codec';\nimport {validCodecs} from '../codec';\n\nexport function validateCodec(\n\tdefaultCodec: unknown,\n\tlocation: string,\n\tname: string,\n): asserts defaultCodec is CodecOrUndefined {\n\tif (typeof defaultCodec === 'undefined') {\n\t\treturn;\n\t}\n\n\tif (typeof defaultCodec !== 'string') {\n\t\tthrow new TypeError(\n\t\t\t`The \"${name}\" prop ${location} must be a string, but you passed a value of type ${typeof defaultCodec}.`,\n\t\t);\n\t}\n\n\tif (!validCodecs.includes(defaultCodec as Codec)) {\n\t\tthrow new Error(\n\t\t\t`The \"${name}\" prop ${location} must be one of ${validCodecs.join(\n\t\t\t\t', ',\n\t\t\t)}, but you passed ${defaultCodec}.`,\n\t\t);\n\t}\n}\n","sourceCodeStart":1,"sourceCodeEnd":27,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/core/src/validation/validate-default-codec.ts#L1-L27","documentation":"`validateCodec` asserts that a codec value (the `defaultCodec` returned from `calculateMetadata`, or the `codec` passed to serverless render APIs) is a string. Passing a non-string (number, object, etc.) throws a TypeError before the codec-list membership check runs. `undefined` is allowed and returns early (meaning 'use default').","triggerScenarios":"Returning `defaultCodec` from a `calculateMetadata` callback as a non-string (e.g. a number, an object, or a mis-typed enum); or calling `renderMediaOnLambda`/`renderMedia` with `codec` set to a non-string value.","commonSituations":"Reading codec from an env var or CLI arg without coercion (`process.env.CODEC` that is sometimes parsed as a number); a JSON config that stores codec as an object `{name:'h264'}`; a refactor that changes the shape of the returned metadata.","solutions":["Ensure the codec value is a string literal or a properly typed variable.","Coerce env/config sources: `const codec = String(config.codec)`.","Return `undefined` (or omit the key) to use the default codec instead of a non-string.","Type the function return as `Codec | undefined` so TypeScript catches it."],"exampleFix":"// before\ncalculateMetadata: () => ({defaultCodec: 264, ...})\n// after\ncalculateMetadata: () => ({defaultCodec: 'h264', ...})","handlingStrategy":"type-guard","validationCode":"if (codec !== undefined && typeof codec !== 'string') {\n  throw new TypeError('codec must be a string or undefined');\n}","typeGuard":"const isCodecString = (c) => c === undefined || typeof c === 'string';","tryCatchPattern":null,"preventionTips":["Type `calculateMetadata` returns as `Codec | undefined`.","Coerce all env/config-derived codec values to string.","Prefer importing the `Codec` type over using loose strings."],"tags":["validation","codec","type","calculate-metadata","serverless"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}