{"record":{"id":"2f847743bbe471df","repo":"remotion-dev/remotion","slug":"name-must-be-formatenum-variants-2f8477","errorCode":null,"errorMessage":"\"${name}\" must be ${formatEnum(variants)}","messagePattern":"\"(.+?)\" must be (.+?)","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"packages/effects/src/halftone.ts","lineNumber":160,"sourceCode":"\t}\n\n\treturn `${variants\n\t\t.slice(0, -1)\n\t\t.map((variant) => `\"${variant}\"`)\n\t\t.join(', ')} or \"${variants[variants.length - 1]}\"`;\n};\n\nconst assertOptionalEnum = <T extends string>(\n\tvalue: unknown,\n\tname: string,\n\tvariants: readonly T[],\n): void => {\n\tif (value === undefined) {\n\t\treturn;\n\t}\n\n\tif (typeof value !== 'string' || !variants.includes(value as T)) {\n\t\tthrow new TypeError(`\"${name}\" must be ${formatEnum(variants)}`);\n\t}\n};\n\nconst resolve = (p: HalftoneParams): HalftoneResolved => ({\n\tshape: p.shape ?? 'circle',\n\tdotSize: p.dotSize ?? 20,\n\tdotSpacing: p.dotSpacing ?? p.dotSize ?? 20,\n\trotation: p.rotation ?? 0,\n\toffsetX: p.offsetX ?? 0,\n\toffsetY: p.offsetY ?? 0,\n\tsampling: p.sampling ?? 'bilinear',\n\tcolorMode: p.colorMode ?? 'solid',\n\tdotColor: 'dotColor' in p ? (p.dotColor ?? 'red') : 'red',\n\tinvert: p.invert ?? false,\n});\n\nconst validateHalftoneParams = (params: HalftoneParams): void => {\n\tassertEffectParamsObject(params, 'Halftone');","sourceCodeStart":142,"sourceCodeEnd":178,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/effects/src/halftone.ts#L142-L178","documentation":"Thrown by assertOptionalEnum() in the halftone effect's validateParams when one of the enum-typed parameters — shape, sampling, or colorMode — is present but not one of the allowed variants. Each parameter has its own allowed list (shape: 'circle'|'square'|'line'; sampling: 'bilinear'|'nearest'; colorMode: 'solid'|'source'), and the message uses formatEnum() to list them, so the actual text names which value was wrong by parameter name.","triggerScenarios":"Passing halftone({ shape: 'triangle' }), halftone({ sampling: 'cubic' }), or halftone({ colorMode: 'gradient' }). Also firing it by passing a non-string (a number, object, or null) to any of these three fields.","commonSituations":"Typos in the enum value; copying example code from an outdated tutorial that used a different spelling; passing the wrong variable (e.g. a color string into shape); dynamically building params from user input without validation.","solutions":["Read the parameter name in the message and set it to one of the listed variants.","If you are typing values, import HalftoneShape / HalftoneSampling / HalftoneColorMode and let TypeScript narrow the literal union for you.","If params come from dynamic input, validate against the allowed list before calling halftone()."],"exampleFix":"// before\nhalftone({ shape: 'circle', colorMode: 'grayscale' })\n\n// after\nhalftone({ shape: 'circle', colorMode: 'source' })","handlingStrategy":"type-guard","validationCode":"import type { HalftoneShape, HalftoneSampling, HalftoneColorMode } from '@remotion/effects';\n\nconst SHAPES = ['circle', 'square', 'line'] as const;\nconst SAMPLING = ['bilinear', 'nearest'] as const;\nconst COLOR_MODES = ['solid', 'source'] as const;\n\nfunction isHalftoneEnum(value: unknown, allowed: readonly string[]): value is string {\n  return typeof value === 'string' && (allowed as readonly string[]).includes(value);\n}\n\n// before calling halftone():\nif (params.shape !== undefined && !isHalftoneEnum(params.shape, SHAPES)) {\n  throw new Error(`shape must be one of ${SHAPES.join(', ')}`);\n}","typeGuard":"function isHalftoneShape(v: unknown): v is HalftoneShape {\n  return v === 'circle' || v === 'square' || v === 'line';\n}\nfunction isHalftoneSampling(v: unknown): v is HalftoneSampling {\n  return v === 'bilinear' || v === 'nearest';\n}\nfunction isHalftoneColorMode(v: unknown): v is HalftoneColorMode {\n  return v === 'solid' || v === 'source';\n}","tryCatchPattern":null,"preventionTips":["Import HalftoneShape / HalftoneSampling / HalftoneColorMode and let TypeScript narrow literal unions at the call site.","When params come from dynamic input (UI, JSON), validate against the allowed list before calling halftone().","Avoid building enum values by string concatenation; use string literals."],"tags":["halftone","validation","enum","typescript","params"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}