{"record":{"id":"9e223f45983dbaf9","repo":"remotion-dev/remotion","slug":"rays-must-be-a-finite-number-but-got-json-str","errorCode":null,"errorMessage":"\"rays\" must be a finite number, but got ${JSON.stringify(rays)}","messagePattern":"\"rays\" must be a finite number, but got (.+?)","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"packages/effects/src/starburst.ts","lineNumber":100,"sourceCode":"const resolve = (p: StarburstEffectParams): StarburstResolved => ({\n\trays: p.rays,\n\tcolors: p.colors,\n\trotation: p.rotation ?? 0,\n\tsmoothness: p.smoothness ?? 0,\n\torigin: (p.origin ?? DEFAULT_ORIGIN) as StarburstOrigin,\n});\n\nconst validateStarburstEffectParams = (params: StarburstEffectParams): void => {\n\tif (params === null || typeof params !== 'object') {\n\t\tthrow new TypeError(\n\t\t\t`Starburst effect requires a parameters object, but got ${JSON.stringify(params)}`,\n\t\t);\n\t}\n\n\tconst {rays, colors} = params;\n\n\tif (typeof rays !== 'number' || !Number.isFinite(rays)) {\n\t\tthrow new TypeError(\n\t\t\t`\"rays\" must be a finite number, but got ${JSON.stringify(rays)}`,\n\t\t);\n\t}\n\n\tif (rays < 2 || rays > 100) {\n\t\tthrow new RangeError(`\"rays\" must be between 2 and 100, but got ${rays}`);\n\t}\n\n\tif (!Array.isArray(colors) || colors.length < 2) {\n\t\tthrow new TypeError(\n\t\t\t`\"colors\" must be an array with at least 2 colors, but got ${JSON.stringify(colors)}`,\n\t\t);\n\t}\n\n\tconst r = resolve(params);\n\n\tif (typeof r.rotation !== 'number' || !Number.isFinite(r.rotation)) {\n\t\tthrow new TypeError(","sourceCodeStart":82,"sourceCodeEnd":118,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/effects/src/starburst.ts#L82-L118","documentation":"validateStarburstEffectParams() throws this TypeError when params.rays is missing, not a number, NaN, or Infinity (checked via typeof === 'number' && Number.isFinite). `rays` is a required field on StarburstEffectParams (it has no default), so it must be supplied as a finite integer.","triggerScenarios":"Calling starburst() with rays omitted, set to undefined, a string like '12', NaN, or Infinity; or passing a floating value that was meant for a different field. The check runs before the range check, so even a finite-but-out-of-range value passes this guard and fails at error 915 instead.","commonSituations":"Forgetting the required `rays` field; reading rays from an input that yields undefined; passing a string from a form field without coercion; math that produced NaN (e.g. dividing by zero) feeding into rays.","solutions":["Provide a finite integer for rays, e.g. starburst({ rays: 12, colors: [...] }).","If rays comes from user input, coerce and validate it (Number.parseInt then Number.isFinite) before calling starburst().","Add a TypeScript type (rays: number) so the compiler flags missing or mistyped values.","Double-check the value is not the result of NaN-producing arithmetic upstream."],"exampleFix":"// before\nstarburst({ rays: NaN, colors: ['#ff0000', '#00ff00'] });\nstarburst({ rays: '12', colors: ['#ff0000', '#00ff00'] });\n\n// after\nstarburst({ rays: 12, colors: ['#ff0000', '#00ff00'] });","handlingStrategy":"validation","validationCode":"function assertRays(v: unknown): number {\n  if (typeof v !== 'number' || !Number.isFinite(v)) {\n    throw new TypeError(`\"rays\" must be a finite number, but got ${JSON.stringify(v)}`);\n  }\n  return v;\n}\n\nstarburst({ rays: assertRays(input.rays), colors });","typeGuard":"function isFiniteNumber(v: unknown): v is number {\n  return typeof v === 'number' && Number.isFinite(v);\n}","tryCatchPattern":"try {\n  starburst({ rays, colors });\n} catch (err) {\n  if (err instanceof TypeError && /\"rays\" must be a finite number/.test(err.message)) {\n    console.error('starburst() rays must be a finite number:', rays);\n    throw err;\n  }\n  throw err;\n}","preventionTips":["Always supply rays as a finite integer.","Coerce and validate untrusted input with Number() + Number.isFinite before calling starburst().","Annotate the source variable as number in TypeScript.","Watch for NaN-producing arithmetic feeding into rays."],"tags":["validation","effects","starburst","typescript","parameters"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}