{"record":{"id":"96ebd7df0dbe0cd4","repo":"remotion-dev/remotion","slug":"codec-must-be-a-string-96ebd7","errorCode":null,"errorMessage":"\"codec\" must be a string ","messagePattern":"\"codec\" must be a string ","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"packages/lambda-client/src/validate-lambda-codec.ts","lineNumber":7,"sourceCode":"/* eslint-disable no-console */\nimport type {ServerlessCodec} from '@remotion/serverless-client';\nimport {serverlessCodecs} from '@remotion/serverless-client';\n\nexport const validateLambdaCodec = (codec: unknown): ServerlessCodec => {\n\tif (typeof codec !== 'string') {\n\t\tthrow new TypeError('\"codec\" must be a string ');\n\t}\n\n\tif (!(serverlessCodecs as readonly string[]).includes(codec)) {\n\t\tthrow new TypeError(\n\t\t\t\"'\" +\n\t\t\t\tcodec +\n\t\t\t\t\"' is not a valid codec for Lambda. The following values are supported: \" +\n\t\t\t\tserverlessCodecs.join(', '),\n\t\t);\n\t}\n\n\tif ((codec as string) === 'h264-mkv') {\n\t\tconsole.warn(\n\t\t\t'The \"h264-mkv\" codec for renderMediaOnLambda() is deprecated - it\\'s now just \"h264\".',\n\t\t);\n\n\t\treturn 'h264';\n\t}","sourceCodeStart":1,"sourceCodeEnd":25,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/lambda-client/src/validate-lambda-codec.ts#L1-L25","documentation":"First guard in validateLambdaCodec: the codec argument must be a string. Any non-string (undefined, null, number, object) throws a TypeError. (Note: the message has a trailing space, which is a minor source artifact.) The codec is validated against the serverlessCodecs allowlist only after this passes.","triggerScenarios":"Calling renderMediaOnLambda/renderStillOnLambda or any path that runs validateLambdaCodec with a non-string codec value (e.g., undefined from a missing config field, a number, or an object).","commonSituations":"Codec option defaulted to undefined; reading codec from config where the field is missing; passing a codec constant that resolved to undefined after a refactor; spread of an options object without codec.","solutions":["Pass a string codec such as 'h264', 'h265', 'vp8', 'vp9', 'mp3', 'aac', 'wav', or 'gif' (see serverlessCodecs).","Provide a sensible default (e.g., 'h264') when codec is not configured.","Type your options object so codec is required string to catch this at compile time."],"exampleFix":"// before\nrenderMediaOnLambda({ composition: 'Main', codec: undefined });\n\n// after\nrenderMediaOnLambda({ composition: 'Main', codec: 'h264' });","handlingStrategy":"type-guard","validationCode":"if (typeof codec !== 'string') {\n  throw new TypeError(`codec must be a string, got ${typeof codec}`);\n}\nvalidateLambdaCodec(codec);","typeGuard":"const isString = (v: unknown): v is string => typeof v === 'string';","tryCatchPattern":null,"preventionTips":["Type codec as string (or a codec union) in options interfaces.","Default to 'h264' when codec is undefined.","Fail fast at the config boundary if codec is missing."],"tags":["input-validation","codec","typescript","type-error"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}