{"record":{"id":"f600547df87a1ce4","repo":"remotion-dev/remotion","slug":"cloudwatch-retention-period-should-be-a-number-go","errorCode":null,"errorMessage":"CloudWatch retention period should be a number, got: ${JSON.stringify(period)}","messagePattern":"CloudWatch retention period should be a number, got: (.+?)","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"packages/lambda/src/shared/validate-retention-period.ts","lineNumber":10,"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","sourceCodeStart":1,"sourceCodeEnd":28,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/lambda/src/shared/validate-retention-period.ts#L1-L28","documentation":"Thrown by validateCloudWatchRetentionPeriod() (a TypeError) when the cloudWatchLogRetentionPeriodInDays value passed to deployFunction() is neither null/undefined nor a number. null/undefined are explicitly allowed (no retention set); anything else is rejected.","triggerScenarios":"Passing deployFunction({cloudWatchLogRetentionPeriodInDays: ...}) with a string like '7', a boolean, or an object.","commonSituations":"Reading the value from an env var (always a string) without converting; deserialised config where the number became a string; copy-pasting docs that quote the number.","solutions":["Pass a number literal (e.g. 7) or omit/null the field.","Convert env-string values with Number() and validate before calling deployFunction.","Type the config field as number | null so TypeScript enforces it."],"exampleFix":"// before\ndeployFunction({region, cloudWatchLogRetentionPeriodInDays: process.env.RETENTION})\n// after\nconst retention = process.env.RETENTION ? Number(process.env.RETENTION) : undefined\ndeployFunction({region, cloudWatchLogRetentionPeriodInDays: retention})","handlingStrategy":"type-guard","validationCode":"if (period !== null && period !== undefined && typeof period !== 'number') {\n  throw new TypeError('cloudWatchLogRetentionPeriodInDays must be a number or null/undefined')\n}","typeGuard":"const isRetentionInput = (v: unknown): v is number | null | undefined =>\n  v === null || v === undefined || typeof v === 'number'","tryCatchPattern":null,"preventionTips":["Coerce env-sourced retention with Number() only after an emptiness check.","Type the config field as `number | null | undefined`.","Use a schema validator at the config boundary."],"tags":["aws","cloudwatch","validation","typescript","configuration"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}