{"record":{"id":"7b88fa3867c94e26","repo":"remotion-dev/remotion","slug":"parameter-disksizeinmb-must-not-be-nan-but-is","errorCode":null,"errorMessage":"parameter 'diskSizeInMb' must not be NaN, but is","messagePattern":"parameter 'diskSizeInMb' must not be NaN, but is","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"packages/lambda-client/src/validate-disk-size-in-mb.ts","lineNumber":14,"sourceCode":"import {\n\tMAX_EPHEMERAL_STORAGE_IN_MB,\n\tMIN_EPHEMERAL_STORAGE_IN_MB,\n} from './constants';\n\nexport const validateDiskSizeInMb = (diskSizeInMb: unknown) => {\n\tif (typeof diskSizeInMb !== 'number') {\n\t\tthrow new TypeError(\n\t\t\t`parameter 'diskSizeInMb' must be a number, got a ${typeof diskSizeInMb}`,\n\t\t);\n\t}\n\n\tif (Number.isNaN(diskSizeInMb)) {\n\t\tthrow new TypeError(`parameter 'diskSizeInMb' must not be NaN, but is`);\n\t}\n\n\tif (!Number.isFinite(diskSizeInMb)) {\n\t\tthrow new TypeError(\n\t\t\t`parameter 'diskSizeInMb' must be finite, but is ${diskSizeInMb}`,\n\t\t);\n\t}\n\n\tif (\n\t\tdiskSizeInMb < MIN_EPHEMERAL_STORAGE_IN_MB ||\n\t\tdiskSizeInMb > MAX_EPHEMERAL_STORAGE_IN_MB\n\t) {\n\t\tthrow new TypeError(\n\t\t\t`parameter 'diskSizeInMb' must be between ${MIN_EPHEMERAL_STORAGE_IN_MB} and ${MAX_EPHEMERAL_STORAGE_IN_MB}, but got ${diskSizeInMb}`,\n\t\t);\n\t}\n\n\tif (diskSizeInMb % 1 !== 0) {","sourceCodeStart":1,"sourceCodeEnd":32,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/lambda-client/src/validate-disk-size-in-mb.ts#L1-L32","documentation":"Second guard in validateDiskSizeInMb: after confirming the value is a number, it must not be NaN. NaN passes typeof === 'number' but represents an unparseable numeric, so this catches Number('abc')-style inputs that slipped past the type check.","triggerScenarios":"Calling validateDiskSizeInMb with the literal NaN, or with Number(someUnparseableString) (e.g., Number('big-disk')) that yields NaN.","commonSituations":"Coercing a non-numeric env var with Number() and passing the NaN result; arithmetic on undefined producing NaN; JSON parse yielding NaN-shaped values.","solutions":["Validate the source string parses cleanly with !Number.isNaN(Number(x)) before calling.","Provide a numeric default when the env var is absent.","Log the raw input value to find where NaN originates."],"exampleFix":"// before\nconst disk = Number(readConfig().diskSize); // NaN if config missing/garbage\nvalidateDiskSizeInMb(disk);\n\n// after\nconst raw = readConfig().diskSize;\nconst disk = raw == null || Number.isNaN(Number(raw)) ? 2048 : Number(raw);\nvalidateDiskSizeInMb(disk);","handlingStrategy":"validation","validationCode":"const disk = Number(diskSizeInMb);\nif (Number.isNaN(disk)) {\n  throw new TypeError(`diskSizeInMb is NaN; source value was ${diskSizeInMb}`);\n}\nvalidateDiskSizeInMb(disk);","typeGuard":"const isNonNaNNumber = (v: unknown): v is number =>\n  typeof v === 'number' && !Number.isNaN(v);","tryCatchPattern":null,"preventionTips":["Validate Number.isNaN() at the config boundary.","Provide a numeric default when env vars are missing.","Log raw string inputs that fail to parse."],"tags":["input-validation","disk","nan","type-error"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}