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 gridlines' validatePositive helper (gridlines.ts:195) when a parameter that must be strictly positive is <= 0. In Gridlines it guards gridSize, which controls spacing between lines and cannot be zero or negative. The message names the offending field and echoes the bad value via JSON.stringify.

Source

Thrown at packages/effects/src/gridlines.ts:197

};

const resolve = (p: GridlinesParams): GridlinesResolved => ({
	gridSize: p.gridSize ?? DEFAULT_GRID_SIZE,
	lineWidth: p.lineWidth ?? DEFAULT_LINE_WIDTH,
	lineColor: p.lineColor ?? DEFAULT_LINE_COLOR,
	backgroundColor: p.backgroundColor ?? DEFAULT_BACKGROUND_COLOR,
	rotation: p.rotation ?? DEFAULT_ROTATION,
	rotationX: p.rotationX ?? DEFAULT_ROTATION_X,
	rotationY: p.rotationY ?? DEFAULT_ROTATION_Y,
	perspective: p.perspective ?? DEFAULT_PERSPECTIVE,
	offsetX: p.offsetX ?? DEFAULT_OFFSET_X,
	offsetY: p.offsetY ?? DEFAULT_OFFSET_Y,
	maskToSourceAlpha: p.maskToSourceAlpha ?? DEFAULT_MASK_TO_SOURCE_ALPHA,
});

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 validateNonNegative = (value: number, name: string): void => {
	if (value < 0) {
		throw new TypeError(
			`"${name}" must be greater than or equal to 0, but got ${JSON.stringify(value)}`,
		);
	}
};

const validateGridlinesParams = (params: GridlinesParams): void => {
	assertEffectParamsObject(params, 'Gridlines');
	assertOptionalFiniteNumber(params.gridSize, 'gridSize');
	assertOptionalFiniteNumber(params.lineWidth, 'lineWidth');
	assertOptionalFiniteNumber(params.rotation, 'rotation');

View on GitHub (pinned to 78fe4bb3fd)

Solutions

  1. Set gridSize to a strictly positive number (e.g. 32).
  2. If animating, clamp the lower bound above 0: Math.max(1, value).
  3. Derive gridSize from a positive source and guard the divisor: ensure width/columns keeps the result > 0.

Example fix

// before
<Gridlines gridSize={Math.floor(width / columns)} />
// columns > width -> gridSize = 0 -> TypeError

// after
<Gridlines gridSize={Math.max(1, Math.floor(width / columns))} />
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: validateGridlinesParams calls validatePositive(params.gridSize ?? DEFAULT_GRID_SIZE, 'gridSize') (gridlines.ts:225). Triggered by passing gridSize: 0, a negative gridSize, or relying on a default of 0. (NaN/Infinity are rejected earlier by assertOptionalFiniteNumber, so this path is specifically finite <= 0 values.)

Common situations: Passing gridSize: 0 to disable lines, animating gridSize through 0, computing gridSize from a formula that can hit zero (e.g. width / columns with columns larger than width), or copy-pasting a config from another effect whose units differ.

Related errors


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