remotion-dev/remotion · error · TypeError

CloudWatch retention period should be a number, got: ${JSON.

Error message

CloudWatch retention period should be a number, got: ${JSON.stringify(period)}

What it means

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.

Source

Thrown at packages/lambda/src/shared/validate-retention-period.ts:10

const MIN_RETENTION_PERIOD = 1;
const MAX_RETENTION_PERIOD = 10 * 365;

export const validateCloudWatchRetentionPeriod = (period: unknown) => {
	if (period === null || period === undefined) {
		return;
	}

	if (typeof period !== 'number') {
		throw new TypeError(
			`CloudWatch retention period should be a number, got: ${JSON.stringify(
				period,
			)}`,
		);
	}

	if (Number.isNaN(period)) {
		throw new TypeError(
			`CloudWatch retention period must be an integer, but is NaN`,
		);
	}

	if (!Number.isFinite(period)) {
		throw new TypeError(
			`CloudWatch retention period must be finite, but is ${period}`,
		);
	}

View on GitHub (pinned to 78fe4bb3fd)

Solutions

  1. Pass a number literal (e.g. 7) or omit/null the field.
  2. Convert env-string values with Number() and validate before calling deployFunction.
  3. Type the config field as number | null so TypeScript enforces it.

Example fix

// before
deployFunction({region, cloudWatchLogRetentionPeriodInDays: process.env.RETENTION})
// after
const retention = process.env.RETENTION ? Number(process.env.RETENTION) : undefined
deployFunction({region, cloudWatchLogRetentionPeriodInDays: retention})
Defensive patterns

Strategy: type-guard

Validate before calling

if (period !== null && period !== undefined && typeof period !== 'number') {
  throw new TypeError('cloudWatchLogRetentionPeriodInDays must be a number or null/undefined')
}

Type guard

const isRetentionInput = (v: unknown): v is number | null | undefined =>
  v === null || v === undefined || typeof v === 'number'

Prevention

When it happens

Trigger: Passing deployFunction({cloudWatchLogRetentionPeriodInDays: ...}) with a string like '7', a boolean, or an object.

Common situations: 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.

Related errors


AI-assisted analysis of remotion-dev/remotion@78fe4bb3fd (2026-08-12). Data as JSON: /api/errors/f600547df87a1ce4. Report an issue: GitHub.