{"record":{"id":"9716e4ab3d04a862","repo":"remotion-dev/remotion","slug":"dotcolor-can-only-be-set-when-colormode-is-so-9716e4","errorCode":null,"errorMessage":"\"dotColor\" can only be set when \"colorMode\" is \"solid\"","messagePattern":"\"dotColor\" can only be set when \"colorMode\" is \"solid\"","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"packages/effects/src/halftone.ts","lineNumber":192,"sourceCode":"\tinvert: p.invert ?? false,\n});\n\nconst validateHalftoneParams = (params: HalftoneParams): void => {\n\tassertEffectParamsObject(params, 'Halftone');\n\tassertOptionalFiniteNumber(params.dotSize, 'dotSize');\n\tassertOptionalFiniteNumber(params.dotSpacing, 'dotSpacing');\n\tassertOptionalFiniteNumber(params.rotation, 'rotation');\n\tassertOptionalFiniteNumber(params.offsetX, 'offsetX');\n\tassertOptionalFiniteNumber(params.offsetY, 'offsetY');\n\tassertOptionalEnum(params.shape, 'shape', HALFTONE_SHAPES);\n\tassertOptionalEnum(params.sampling, 'sampling', HALFTONE_SAMPLING);\n\tassertOptionalEnum(params.colorMode, 'colorMode', HALFTONE_COLOR_MODES);\n\tif ('color' in params && params.color !== undefined) {\n\t\tthrow new TypeError('\"color\" has been renamed to \"dotColor\"');\n\t}\n\n\tif (params.colorMode === 'source' && 'dotColor' in params) {\n\t\tthrow new TypeError(\n\t\t\t'\"dotColor\" can only be set when \"colorMode\" is \"solid\"',\n\t\t);\n\t}\n\n\tassertOptionalColor(\n\t\t'dotColor' in params ? params.dotColor : undefined,\n\t\t'dotColor',\n\t);\n\tassertOptionalBoolean(params.invert, 'invert');\n\n\tif (params.dotSize !== undefined && params.dotSize < 1) {\n\t\tthrow new TypeError(\n\t\t\t`\"dotSize\" must be >= 1, but got ${JSON.stringify(params.dotSize)}`,\n\t\t);\n\t}\n\n\tif (params.dotSpacing !== undefined && params.dotSpacing < 1) {\n\t\tthrow new TypeError(","sourceCodeStart":174,"sourceCodeEnd":210,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/effects/src/halftone.ts#L174-L210","documentation":"Thrown by validateHalftoneParams() when params.colorMode === 'source' AND a 'dotColor' key is present on the params object. In source color mode the dots take their color from the underlying frame, so a solid dotColor is contradictory; the library forbids the combination explicitly rather than silently dropping the value. Note the check is on key presence ('dotColor' in params), so even dotColor: undefined is allowed — only an explicitly-set dotColor trips it.","triggerScenarios":"Calling halftone({ colorMode: 'source', dotColor: 'red' }) or destructuring a params object that always includes dotColor and then switching colorMode to 'source'.","commonSituations":"Toggling colorMode dynamically (e.g. from Studio Visual Mode or a control panel) while leaving dotColor set; sharing one params object across modes; conditional spreads that always include dotColor.","solutions":["When colorMode is 'source', omit dotColor entirely from the params object.","Build the params object conditionally: only add dotColor when colorMode is 'solid' (or undefined).","If you need both code paths, branch on colorMode before constructing params."],"exampleFix":"// before\nhalftone({ colorMode: 'source', dotColor: 'red' })\n\n// after\nconst params = { colorMode: mode };\nif (mode === 'solid') params.dotColor = 'red';\nhalftone(params)","handlingStrategy":"type-guard","validationCode":"// Build params conditionally so dotColor is only present in solid mode.\nfunction buildHalftoneParams(colorMode: 'solid' | 'source', dotColor?: string) {\n  const params: Record<string, unknown> = { colorMode };\n  if (colorMode === 'solid' && dotColor !== undefined) params.dotColor = dotColor;\n  return params;\n}","typeGuard":"// Detect the conflicting combination before calling halftone().\nfunction isConflictingHalftoneCombo(p: unknown): boolean {\n  return typeof p === 'object' && p !== null\n    && (p as { colorMode?: unknown }).colorMode === 'source'\n    && 'dotColor' in p;\n}","tryCatchPattern":null,"preventionTips":["Construct the params object with a conditional spread: { ...(mode === 'solid' ? { dotColor } : {}) }.","When toggling colorMode from a control panel, also clear dotColor from the params object.","Branch on colorMode before assembling params, not after."],"tags":["halftone","params","conflict","validation","color-mode"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}