{"record":{"id":"b2a54917e23571ec","repo":"remotion-dev/remotion","slug":"codec-must-be-a-string","errorCode":null,"errorMessage":"\"codec\" must be a string ","messagePattern":"\"codec\" must be a string ","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"packages/cloudrun/src/shared/validate-gcp-codec.ts","lineNumber":16,"sourceCode":"const cloudrunCodecs = [\n\t'h264',\n\t'vp8',\n\t'vp9',\n\t'mp3',\n\t'aac',\n\t'wav',\n\t'gif',\n\t'prores',\n] as const;\n\nexport type CloudrunCodec = (typeof cloudrunCodecs)[number];\n\nexport const validateCloudrunCodec = (codec: unknown): CloudrunCodec => {\n\tif (typeof codec !== 'string') {\n\t\tthrow new TypeError('\"codec\" must be a string ');\n\t}\n\n\tif (!(cloudrunCodecs 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 GCP Cloud Run. The following values are supported: \" +\n\t\t\t\tcloudrunCodecs.join(', '),\n\t\t);\n\t}\n\n\tif (codec === 'h264-mkv') {\n\t\tthrow new Error(\n\t\t\t'The \"h264-mkv\" codec for renderMediaOnCloudrun() is deprecated - it\\'s now just \"h264\".',\n\t\t);\n\t}\n\n\treturn codec as CloudrunCodec;","sourceCodeStart":1,"sourceCodeEnd":34,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/cloudrun/src/shared/validate-gcp-codec.ts#L1-L34","documentation":"Thrown by validateCloudrunCodec() when the codec argument is not a string (note the trailing space in the message, a cosmetic bug). This is the type guard before the codec allow-list check. Cloud Run supports a fixed subset of codecs, so a non-string value cannot be validated further.","triggerScenarios":"Passing a non-string codec (undefined, null, number) to renderMediaOnCloudRun(), or reading codec from config where it is unset.","commonSituations":"Codec sourced from an env var or JSON config that omits the value; passing an options object where a string was expected.","solutions":["Pass an explicit codec string from the supported list: h264, vp8, vp9, mp3, aac, wav, gif, prores.","Default codec to 'h264' if your config does not specify one.","Validate config at startup before invoking renderMediaOnCloudRun()."],"exampleFix":"// before\nconst { CODEC } = process.env; // undefined\nawait renderMediaOnCloudRun({ codec: CODEC, ... });\n// after\nconst codec = process.env.CODEC ?? 'h264';\nawait renderMediaOnCloudRun({ codec, ... });","handlingStrategy":"type-guard","validationCode":"import { validateCloudrunCodec } from '@remotion/cloudrun/shared';\nvalidateCloudrunCodec(codec);","typeGuard":"function isCodecString(v: unknown): v is string {\n  return typeof v === 'string';\n}","tryCatchPattern":"const codec = typeof inputCodec === 'string' ? inputCodec : 'h264';","preventionTips":["Default codec to 'h264' when config omits it.","Type your render config so non-string codecs fail at compile time.","Validate config before invoking render APIs."],"tags":["cloudrun","validation","typescript","codec"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}