{"record":{"id":"3720f1409037f7f1","repo":"remotion-dev/remotion","slug":"memory-size-must-be-a-positive-integer-received","errorCode":null,"errorMessage":"Memory size must be a positive integer. Received: ${memorySizeInMb}","messagePattern":"Memory size must be a positive integer\\. Received: (.+?)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/lambda-client/src/speculate-function-name.ts","lineNumber":38,"sourceCode":"\t\t`${timeoutInSeconds}sec`,\n\t].join('-');\n};\n\n/*\n * @description Speculate the name of the Lambda function that will be created by `deployFunction()` or its CLI equivalent, based on the function configuration.\n * @see [Documentation](https://remotion.dev/docs/lambda/speculatefunctionname)\n */\nexport const speculateFunctionName = ({\n\tmemorySizeInMb,\n\tdiskSizeInMb,\n\ttimeoutInSeconds,\n}: SpeculateFunctionNameInput) => {\n\tconst memorySize = Number(memorySizeInMb);\n\tconst diskSize = Number(diskSizeInMb);\n\tconst timeout = Number(timeoutInSeconds);\n\n\tif (!Number.isInteger(memorySize) || memorySize <= 0) {\n\t\tthrow new Error(\n\t\t\t`Memory size must be a positive integer. Received: ${memorySizeInMb}`,\n\t\t);\n\t}\n\n\tif (!Number.isInteger(diskSize) || diskSize <= 0) {\n\t\tthrow new Error(\n\t\t\t`Disk size must be a positive integer. Received: ${diskSizeInMb}`,\n\t\t);\n\t}\n\n\tif (!Number.isInteger(timeout) || timeout <= 0) {\n\t\tthrow new Error(\n\t\t\t`Timeout must be a positive integer. Received: ${timeoutInSeconds}`,\n\t\t);\n\t}\n\n\treturn innerSpeculateFunctionName({\n\t\tdiskSizeInMb,","sourceCodeStart":20,"sourceCodeEnd":56,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/lambda-client/src/speculate-function-name.ts#L20-L56","documentation":"speculateFunctionName validates its inputs before composing the Lambda function name. memorySizeInMb is coerced via Number(); if the result is not an integer or is <= 0, this error is thrown. The input type is string|number, so non-numeric strings produce NaN and fail this check.","triggerScenarios":"Calling speculateFunctionName (or deployFunction's name prediction) with memorySizeInMb that Number() cannot turn into a positive integer — e.g. 0, -1, 2048.5, 'abc', '', null, undefined.","commonSituations":"Reading memorySizeInMb from an env var or CLI arg as a string and passing an empty/garbage value; passing a fractional value; defaulting to 0; off-by-one in config builders.","solutions":["Pass a positive integer for memorySizeInMb (Lambda allows 128 to 10240 in 1-MB steps; Remotion recommends >= 512).","If reading from env, validate and coerce with Number() and Number.isInteger() before calling.","Use validateMemorySize() from the same package for full range validation."],"exampleFix":"// before\nspeculateFunctionName({ memorySizeInMb: 'fast', diskSizeInMb: 2048, timeoutInSeconds: 120 });\n\n// after\nspeculateFunctionName({ memorySizeInMb: 2048, diskSizeInMb: 2048, timeoutInSeconds: 120 });","handlingStrategy":"validation","validationCode":"const mem = Number(memorySizeInMb);\nif (!Number.isInteger(mem) || mem <= 0) {\n  throw new Error(`memorySizeInMb must be a positive integer, got ${memorySizeInMb}`);\n}\nspeculateFunctionName({ memorySizeInMb: mem, diskSizeInMb, timeoutInSeconds });","typeGuard":"const isPositiveInteger = (v: unknown): v is number =>\n  typeof v === 'number' && Number.isInteger(v) && v > 0;","tryCatchPattern":null,"preventionTips":["Always pass memorySizeInMb as a number literal in config.","Coerce string env values with Number() and validate isInteger before use.","Use validateMemorySize() for full range validation."],"tags":["input-validation","lambda","memory","configuration"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}