remotion-dev/remotion · error · RangeError

"rays" must be between 2 and 100, but got ${rays}

Error message

"rays" must be between 2 and 100, but got ${rays}

What it means

validateStarburstEffectParams() throws this RangeError when params.rays is a finite number but outside the supported [2, 100] range. The schema (starburstEffectSchema.rays) declares min 2 and max 100, and this check enforces it at runtime; fewer than 2 rays cannot form a starburst pattern and more than 100 over-subdivides the circle.

Source

Thrown at packages/effects/src/starburst.ts:106

});

const validateStarburstEffectParams = (params: StarburstEffectParams): void => {
	if (params === null || typeof params !== 'object') {
		throw new TypeError(
			`Starburst effect requires a parameters object, but got ${JSON.stringify(params)}`,
		);
	}

	const {rays, colors} = params;

	if (typeof rays !== 'number' || !Number.isFinite(rays)) {
		throw new TypeError(
			`"rays" must be a finite number, but got ${JSON.stringify(rays)}`,
		);
	}

	if (rays < 2 || rays > 100) {
		throw new RangeError(`"rays" must be between 2 and 100, but got ${rays}`);
	}

	if (!Array.isArray(colors) || colors.length < 2) {
		throw new TypeError(
			`"colors" must be an array with at least 2 colors, but got ${JSON.stringify(colors)}`,
		);
	}

	const r = resolve(params);

	if (typeof r.rotation !== 'number' || !Number.isFinite(r.rotation)) {
		throw new TypeError(
			`"rotation" must be a finite number, but got ${JSON.stringify(params.rotation)}`,
		);
	}

	if (typeof r.smoothness !== 'number' || !Number.isFinite(r.smoothness)) {
		throw new TypeError(

View on GitHub (pinned to 78fe4bb3fd)

Solutions

  1. Clamp rays to the [2, 100] range before calling starburst(), e.g. Math.min(100, Math.max(2, Math.round(rays))).
  2. Constrain the upstream input (form field, schema) so it cannot produce out-of-range values.
  3. Pick a sensible default within range (e.g. 12) when the input is missing or invalid.
  4. Re-check the schema's min/max in starburstEffectSchema if you believe the limit should differ.

Example fix

// before
starburst({ rays: 150, colors: ['#ff0000', '#00ff00'] });
starburst({ rays: 1, colors: ['#ff0000', '#00ff00'] });

// after
const rays = Math.min(100, Math.max(2, Math.round(inputRays)));
starburst({ rays, colors: ['#ff0000', '#00ff00'] });
Defensive patterns

Strategy: validation

Validate before calling

function clampRays(v: number): number {
  return Math.min(100, Math.max(2, Math.round(v)));
}

starburst({ rays: clampRays(inputRays), colors });

Type guard

function isValidRayCount(v: unknown): v is number {
  return typeof v === 'number' && Number.isFinite(v) && v >= 2 && v <= 100;
}

Try / catch

try {
  starburst({ rays, colors });
} catch (err) {
  if (err instanceof RangeError && /"rays" must be between 2 and 100/.test(err.message)) {
    const clamped = Math.min(100, Math.max(2, Math.round(Number(rays))));
    starburst({ rays: clamped, colors }); // retry with clamped value
    return;
  }
  throw err;
}

Prevention

When it happens

Trigger: Calling starburst({ rays: 1, colors }) (below minimum), starburst({ rays: 150, colors }) (above maximum), or passing a negative/fractional number that is finite. The finite-number guard (error 914) runs first, so only finite out-of-range values reach this check.

Common situations: A slider/input allowing values beyond 2–100; deriving rays from a formula without clamping; copying a value from another tool whose ray scale differs; accidentally passing a count meant for `colors`.

Related errors


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