{"record":{"id":"a586fd9e92366718","repo":"remotion-dev/remotion","slug":"cloudwatch-retention-period-must-be-an-integer-bu","errorCode":null,"errorMessage":"CloudWatch retention period must be an integer, but is NaN","messagePattern":"CloudWatch retention period must be an integer, but is NaN","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"packages/lambda/src/shared/validate-retention-period.ts","lineNumber":18,"sourceCode":"const MIN_RETENTION_PERIOD = 1;\nconst MAX_RETENTION_PERIOD = 10 * 365;\n\nexport const validateCloudWatchRetentionPeriod = (period: unknown) => {\n\tif (period === null || period === undefined) {\n\t\treturn;\n\t}\n\n\tif (typeof period !== 'number') {\n\t\tthrow new TypeError(\n\t\t\t`CloudWatch retention period should be a number, got: ${JSON.stringify(\n\t\t\t\tperiod,\n\t\t\t)}`,\n\t\t);\n\t}\n\n\tif (Number.isNaN(period)) {\n\t\tthrow new TypeError(\n\t\t\t`CloudWatch retention period must be an integer, but is NaN`,\n\t\t);\n\t}\n\n\tif (!Number.isFinite(period)) {\n\t\tthrow new TypeError(\n\t\t\t`CloudWatch retention period must be finite, but is ${period}`,\n\t\t);\n\t}\n\n\tif (period % 1 !== 0) {\n\t\tthrow new TypeError(\n\t\t\t`CloudWatch retention period must be an integer, but is ${period}`,\n\t\t);\n\t}\n\n\tif (period < MIN_RETENTION_PERIOD) {\n\t\tthrow new Error(","sourceCodeStart":1,"sourceCodeEnd":36,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/lambda/src/shared/validate-retention-period.ts#L1-L36","documentation":"Thrown by validateCloudWatchRetentionPeriod() (a TypeError) when the value is a number but is NaN. This typically results from Number('') or Number('not-a-number') coercion producing NaN, which would otherwise pass the typeof number check.","triggerScenarios":"Passing Number('') or Number('abc') as the retention period; arithmetic on undefined that yields NaN; parsing an empty env var with Number().","commonSituations":"Env var empty/unset but coerced with Number() instead of conditional parsing; config typos parsed as NaN; defaulting to a numeric operation that produces NaN.","solutions":["Guard parsing: only convert when the source string is non-empty and numeric.","Use Number.isFinite() on the parsed value before passing it through.","Omit the field (undefined) when no value is configured."],"exampleFix":"// before\nconst retention = Number(process.env.RETENTION)  // '' -> NaN\ndeployFunction({region, cloudWatchLogRetentionPeriodInDays: retention})\n// after\nconst raw = process.env.RETENTION\nconst retention = raw && /^\\d+$/.test(raw) ? Number(raw) : undefined\ndeployFunction({region, cloudWatchLogRetentionPeriodInDays: retention})","handlingStrategy":"validation","validationCode":"if (typeof period === 'number' && Number.isNaN(period)) {\n  throw new TypeError('retention parsed to NaN; check the source string')\n}","typeGuard":"const isFiniteNumber = (v: unknown): v is number => typeof v === 'number' && Number.isFinite(v)","tryCatchPattern":null,"preventionTips":["Parse env values with a strict numeric regex before Number().","Treat empty env strings as 'unset' rather than Number('').","Centralise numeric config parsing in one helper."],"tags":["aws","cloudwatch","validation","typescript","configuration"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}