remotion-dev/remotion · error · TypeError

"${name}" must be greater than 0, but got ${JSON.stringify(v

Error message

"${name}" must be greater than 0, but got ${JSON.stringify(value)}

What it means

TypeError thrown by halftone-linear-gradient's validatePositive (halftone-linear-gradient.ts:202) when a value that must be strictly positive is <= 0. It guards gridSize (the spacing of the halftone cell grid). Zero or negative gridSize is rejected because the grid would be undefined.

Source

Thrown at packages/effects/src/halftone-linear-gradient.ts:204

	] as UvCoordinate,
	gridSize: p.gridSize ?? DEFAULT_GRID_SIZE,
	colorMode: p.colorMode ?? 'solid',
	dotColor:
		'dotColor' in p ? (p.dotColor ?? DEFAULT_DOT_COLOR) : DEFAULT_DOT_COLOR,
	maskToSourceAlpha: p.maskToSourceAlpha ?? DEFAULT_MASK_TO_SOURCE_ALPHA,
});

const validateNonNegative = (value: number, name: string): void => {
	if (value < 0) {
		throw new TypeError(
			`"${name}" must be >= 0, but got ${JSON.stringify(value)}`,
		);
	}
};

const validatePositive = (value: number, name: string): void => {
	if (value <= 0) {
		throw new TypeError(
			`"${name}" must be greater than 0, but got ${JSON.stringify(value)}`,
		);
	}
};

const assertOptionalUvCoordinate = (value: unknown, name: string): void => {
	if (value === undefined) {
		return;
	}

	if (
		!Array.isArray(value) ||
		value.length !== 2 ||
		value.some((item) => typeof item !== 'number' || !Number.isFinite(item))
	) {
		throw new TypeError(`"${name}" must be a [number, number] tuple`);
	}
};

View on GitHub (pinned to 78fe4bb3fd)

Solutions

  1. Set gridSize to a strictly positive number (e.g. 8).
  2. Clamp animated values above zero: Math.max(1, value).
  3. Guard any divisor used to compute gridSize.

Example fix

// before
<halftoneLinearGradient gridSize={Math.floor(width / cols)} />
// cols > width -> gridSize 0

// after
<halftoneLinearGradient gridSize={Math.max(1, Math.floor(width / cols))} />
Defensive patterns

Strategy: validation

Validate before calling

const assertGridSize = (v: number) => {
  if (!Number.isFinite(v) || v <= 0) {
    throw new TypeError(`gridSize must be > 0, got ${v}`);
  }
};
assertGridSize(params.gridSize ?? DEFAULT_GRID_SIZE);

Type guard

const isValidGridSize = (v: unknown): v is number =>
  typeof v === 'number' && Number.isFinite(v) && v > 0;

Try / catch

null

Prevention

When it happens

Trigger: validateHalftoneLinearGradientParams validates gridSize > 0 (around line 259). Triggered by passing gridSize: 0, a negative gridSize, or relying on a default of 0. (Non-finite values are caught earlier by assertOptionalFiniteNumber.)

Common situations: gridSize: 0 to 'disable' halftone; animating gridSize through zero; deriving gridSize from width/columns where columns can exceed width; a typo.

Related errors


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