{"record":{"id":"263f73d8e9e999f9","repo":"remotion-dev/remotion","slug":"palette-must-be-an-array-with-at-least-2-colors","errorCode":null,"errorMessage":"\"palette\" must be an array with at least 2 colors, but got ${JSON.stringify(palette)}","messagePattern":"\"palette\" must be an array with at least 2 colors, but got (.+?)","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"packages/effects/src/thermal-vision.ts","lineNumber":84,"sourceCode":"\t\treadonly uPaletteLength: WebGLUniformLocation | null;\n\t\treadonly uAmount: WebGLUniformLocation | null;\n\t};\n\tcachedPaletteKey: string;\n\tpalettePixelData: Uint8Array;\n};\n\nconst resolve = (p: ThermalVisionParams): ThermalVisionResolved => ({\n\tamount: p.amount ?? DEFAULT_AMOUNT,\n\tpalette: p.palette ?? DEFAULT_PALETTE,\n});\n\nconst validatePalette = (palette: unknown): void => {\n\tif (palette === undefined) {\n\t\treturn;\n\t}\n\n\tif (!Array.isArray(palette) || palette.length < 2) {\n\t\tthrow new TypeError(\n\t\t\t`\"palette\" must be an array with at least 2 colors, but got ${JSON.stringify(palette)}`,\n\t\t);\n\t}\n\n\tfor (let i = 0; i < palette.length; i++) {\n\t\tassertRequiredColor(palette[i], `palette[${i}]`);\n\t}\n};\n\nconst validateThermalVisionParams = (params: ThermalVisionParams): void => {\n\tassertEffectParamsObject(params, 'Thermal vision');\n\tassertOptionalFiniteNumber(params.amount, 'amount');\n\tvalidatePalette(params.palette);\n\n\tconst {amount} = resolve(params);\n\tvalidateUnitInterval(amount, 'amount');\n};\n","sourceCodeStart":66,"sourceCodeEnd":102,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/effects/src/thermal-vision.ts#L66-L102","documentation":"The thermal vision effect's optional `palette` parameter must be an array containing at least 2 color strings. This TypeError is thrown by `validatePalette` (called from `validateThermalVisionParams`) when `palette` is defined but is not an array or has fewer than 2 entries. Note `undefined` is allowed (defaults to an 8-color ramp); only a present-but-invalid value triggers this.","triggerScenarios":"Passing `palette` as a non-array (e.g. `palette: '#ff0000'`), an empty array (`palette: []`), or a single-element array (`palette: ['#ff0000']`). Each element is then separately validated as a color by `assertRequiredColor`.","commonSituations":"Passing a single hex string instead of an array; deserializing a palette from config that was truncated; misunderstanding that at least two colors are needed to form a ramp; accidental `palette: null`.","solutions":["Provide an array of at least 2 valid color strings, e.g. `palette: ['#0000ff', '#ff0000']`.","Omit `palette` to use the built-in default 8-color thermal ramp.","If loading palette from external config, validate its length >= 2 before passing."],"exampleFix":"// before\nthermalVision({palette: ['#0000ff']});\n// after\nthermalVision({palette: ['#0000ff', '#00ff00', '#ff0000']});","handlingStrategy":"validation","validationCode":"const isValidPalette = (p: unknown): p is readonly string[] =>\n  Array.isArray(p) && p.length >= 2 && p.every((c) => typeof c === 'string');\n\nconst palette = loadPaletteFromConfig();\nif (palette !== undefined && !isValidPalette(palette)) {\n  throw new Error('palette must have >= 2 colors');\n}\nthermalVision({palette});","typeGuard":"const isThermalPalette = (v: unknown): v is readonly string[] =>\n  Array.isArray(v) && v.length >= 2 && v.every((c) => typeof c === 'string');","tryCatchPattern":"try {\n  thermalVision({...params});\n} catch (e) {\n  if (e instanceof TypeError && /palette.*at least 2/.test(e.message)) {\n    thermalVision({...params, palette: undefined}); // use default ramp\n  } else throw e;\n}","preventionTips":["Always pass `palette` as an array of at least 2 valid CSS color strings.","When loading palettes from config, assert length >= 2 before use.","Omit `palette` to use the built-in default thermal ramp."],"tags":["thermal-vision","validation","params","palette","color"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}