{"record":{"id":"b324be938733fdca","repo":"remotion-dev/remotion","slug":"parameter-disksizeinmb-must-be-finite-but-is","errorCode":null,"errorMessage":"parameter 'diskSizeInMb' must be finite, but is ${diskSizeInMb}","messagePattern":"parameter 'diskSizeInMb' must be finite, but is (.+?)","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"packages/lambda-client/src/validate-disk-size-in-mb.ts","lineNumber":18,"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) {\n\t\tthrow new TypeError(\n\t\t\t`parameter 'diskSizeInMb' must be an integer but got ${diskSizeInMb}`,\n\t\t);\n\t}","sourceCodeStart":1,"sourceCodeEnd":36,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/lambda-client/src/validate-disk-size-in-mb.ts#L1-L36","documentation":"Third guard in validateDiskSizeInMb: the number must be finite. Infinity/-Infinity pass the typeof and NaN checks but are not valid disk sizes, so Number.isFinite() catches them. The message interpolates the offending value.","triggerScenarios":"Calling validateDiskSizeInMb with Infinity or -Infinity, e.g., from division by zero, Number('Infinity'), or unbounded arithmetic in a config builder.","commonSituations":"Computing disk size from a ratio that divides by zero; reading the literal 'Infinity' from config and coercing; bounds-math bugs producing Infinity.","solutions":["Clamp the computed value with Math.min/Math.max against the valid range before calling.","Reject or default non-finite inputs in your config layer.","Check Number.isFinite() upstream before validation."],"exampleFix":"// before\nconst disk = totalSpace / freeRatio; // Infinity when freeRatio === 0\nvalidateDiskSizeInMb(disk);\n\n// after\nconst disk = Number.isFinite(totalSpace / freeRatio)\n  ? totalSpace / freeRatio\n  : 2048;\nvalidateDiskSizeInMb(disk);","handlingStrategy":"validation","validationCode":"if (!Number.isFinite(diskSizeInMb)) {\n  throw new TypeError(`diskSizeInMb must be finite, got ${diskSizeInMb}`);\n}\nvalidateDiskSizeInMb(diskSizeInMb);","typeGuard":"const isFiniteNumber = (v: unknown): v is number =>\n  typeof v === 'number' && Number.isFinite(v);","tryCatchPattern":null,"preventionTips":["Clamp computed values with Math.min/Math.max before validation.","Guard division-by-zero in disk-size calculations.","Check Number.isFinite() at the config boundary."],"tags":["input-validation","disk","infinity","type-error"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}