{"record":{"id":"0e9b6ef2d288d113","repo":"remotion-dev/remotion","slug":"parameter-memorysizeinmb-must-be-a-number-got-a","errorCode":null,"errorMessage":"parameter 'memorySizeInMb' must be a number, got a ${typeof memorySizeInMb}","messagePattern":"parameter 'memorySizeInMb' must be a number, got a (.+?)","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"packages/lambda-client/src/validate-memory-size.ts","lineNumber":5,"sourceCode":"import {MAX_MEMORY, MIN_MEMORY} from './constants';\n\nexport const validateMemorySize = (memorySizeInMb: unknown) => {\n\tif (typeof memorySizeInMb !== 'number') {\n\t\tthrow new TypeError(\n\t\t\t`parameter 'memorySizeInMb' must be a number, got a ${typeof memorySizeInMb}`,\n\t\t);\n\t}\n\n\tif (Number.isNaN(memorySizeInMb)) {\n\t\tthrow new TypeError(`parameter 'memorySizeInMb' must not be NaN, but is`);\n\t}\n\n\tif (!Number.isFinite(memorySizeInMb)) {\n\t\tthrow new TypeError(\n\t\t\t`parameter 'memorySizeInMb' must be finite, but is ${memorySizeInMb}`,\n\t\t);\n\t}\n\n\tif (memorySizeInMb < MIN_MEMORY || memorySizeInMb > MAX_MEMORY) {\n\t\tthrow new TypeError(\n\t\t\t`parameter 'memorySizeInMb' must be between ${MIN_MEMORY} and ${MAX_MEMORY}, but got ${memorySizeInMb}`,\n\t\t);","sourceCodeStart":1,"sourceCodeEnd":23,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/lambda-client/src/validate-memory-size.ts#L1-L23","documentation":"First guard in validateMemorySize: memorySizeInMb must be of type 'number'. Subsequent checks (NaN, finite, range 512-10240, integer) only run after this passes. Any non-number input throws a TypeError reporting the actual typeof.","triggerScenarios":"Calling validateMemorySize (directly or via deployFunction/render APIs that validate memory) with a non-number value, e.g. a string '2048', undefined, null, or an object.","commonSituations":"Reading memorySizeInMb from env/CLI as a string and passing it uncoerced; defaulting to undefined; JSON config with the memory value quoted.","solutions":["Pass memorySizeInMb as a number literal (e.g., 2048).","Coerce string inputs with Number() before calling, after confirming parseability.","Fix JSON/env config to provide an unquoted numeric value."],"exampleFix":"// before\nvalidateMemorySize(process.env.MEMORY_SIZE); // '2048' (string)\n\n// after\nvalidateMemorySize(Number(process.env.MEMORY_SIZE));","handlingStrategy":"type-guard","validationCode":"if (typeof memorySizeInMb !== 'number') {\n  throw new TypeError(`memorySizeInMb must be a number, got ${typeof memorySizeInMb}`);\n}\nvalidateMemorySize(memorySizeInMb);","typeGuard":"const isNumber = (v: unknown): v is number => typeof v === 'number';","tryCatchPattern":null,"preventionTips":["Type memorySizeInMb as number in all config interfaces.","Coerce string env values with Number() before validation.","Use unquoted numeric values in JSON config."],"tags":["input-validation","memory","typescript","type-error"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}