{"record":{"id":"256d226d1749cee8","repo":"remotion-dev/remotion","slug":"colors-must-be-an-array-with-at-least-2-colors-256d22","errorCode":null,"errorMessage":"\"colors\" must be an array with at least 2 colors, but got ${JSON.stringify(colors)}","messagePattern":"\"colors\" must be an array with at least 2 colors, but got (.+?)","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"packages/effects/src/starburst.ts","lineNumber":110,"sourceCode":"\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(\n\t\t\t`\"rotation\" must be a finite number, but got ${JSON.stringify(params.rotation)}`,\n\t\t);\n\t}\n\n\tif (typeof r.smoothness !== 'number' || !Number.isFinite(r.smoothness)) {\n\t\tthrow new TypeError(\n\t\t\t`\"smoothness\" must be a finite number, but got ${JSON.stringify(params.smoothness)}`,\n\t\t);\n\t}\n","sourceCodeStart":92,"sourceCodeEnd":128,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/effects/src/starburst.ts#L92-L128","documentation":"validateStarburstEffectParams() throws this TypeError when params.colors is not an array or has fewer than 2 entries. The starburst pattern alternates between colors around the circle, so at least two are mandatory; a single color or a non-array cannot produce the effect and the GLSL palette sampler would be degenerate.","triggerScenarios":"Calling starburst() with colors omitted, set to a single color string instead of an array (e.g. '#ff0000'), an array of length 0 or 1, or a non-array value like an object. The check is Array.isArray(colors) && colors.length >= 2.","commonSituations":"Passing a bare string where an array is expected; forgetting to wrap the second color; reading colors from config that yielded undefined; spreading a possibly-empty array; a refactor that dropped the array wrapper.","solutions":["Pass an array of at least two color strings: starburst({ rays: 12, colors: ['#ff0000', '#00ff00'] }).","If colors come from dynamic input, guard with Array.isArray(c) && c.length >= 2 before calling starburst().","Provide a fallback palette of >= 2 colors when the source is empty.","Add a TypeScript type (colors: readonly string[]) so the compiler flags non-array or short arrays at build time."],"exampleFix":"// before\nstarburst({ rays: 12, colors: '#ff0000' });\nstarburst({ rays: 12, colors: ['#ff0000'] });\n\n// after\nstarburst({ rays: 12, colors: ['#ff0000', '#00ff00'] });","handlingStrategy":"type-guard","validationCode":"function assertColors(v: unknown): readonly string[] {\n  if (!Array.isArray(v) || v.length < 2) {\n    throw new TypeError('\"colors\" must be an array with at least 2 colors');\n  }\n  return v as readonly string[];\n}\n\nstarburst({ rays, colors: assertColors(input.colors) });","typeGuard":"function isColorsArray(v: unknown): v is readonly string[] {\n  return Array.isArray(v) && v.length >= 2 && v.every((c) => typeof c === 'string');\n}","tryCatchPattern":"try {\n  starburst({ rays, colors });\n} catch (err) {\n  if (err instanceof TypeError && /\"colors\" must be an array with at least 2 colors/.test(err.message)) {\n    console.error('starburst() needs an array of >= 2 color strings:', colors);\n    throw err;\n  }\n  throw err;\n}","preventionTips":["Always pass colors as an array of at least two strings.","Type and guard colors from untrusted sources before calling starburst().","Provide a fallback palette when the source might be empty.","Use the StarburstEffectParams type so the compiler flags short/non-array values."],"tags":["validation","effects","starburst","typescript","parameters"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}