{"record":{"id":"1ac4030ebbf89253","repo":"remotion-dev/remotion","slug":"name-must-be-formatenum-variants-but-got-1ac403","errorCode":null,"errorMessage":"\"${name}\" must be ${formatEnum(variants)}, but got ${JSON.stringify(value)}","messagePattern":"\"(.+?)\" must be (.+?), but got (.+?)","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"packages/effects/src/vignette.ts","lineNumber":158,"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 (!variants.includes(value as T)) {\n\t\tthrow new TypeError(\n\t\t\t`\"${name}\" must be ${formatEnum(variants)}, but got ${JSON.stringify(value)}`,\n\t\t);\n\t}\n};\n\nconst resolve = (p: VignetteParams): VignetteResolved => ({\n\tamount: p.amount ?? DEFAULT_AMOUNT,\n\tradius: p.radius ?? DEFAULT_RADIUS,\n\tfeather: p.feather ?? DEFAULT_FEATHER,\n\troundness: p.roundness ?? DEFAULT_ROUNDNESS,\n\tcolor: p.color ?? DEFAULT_COLOR,\n\tmode: p.mode ?? DEFAULT_MODE,\n\tcenter: [...(p.center ?? DEFAULT_CENTER)] as VignetteCenter,\n});\n\nconst assertOptionalUvCoordinate = (value: unknown, name: string): void => {\n\tif (value === undefined) {\n\t\treturn;","sourceCodeStart":140,"sourceCodeEnd":176,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/effects/src/vignette.ts#L140-L176","documentation":"TypeError thrown by vignette's assertOptionalEnum when params.mode is defined but is not one of the allowed VIGNETTE_MODES (\"color\" or \"alpha\"). Validation runs synchronously when vignette() is called; the offending value is echoed via JSON.stringify so you can see exactly what was rejected.","triggerScenarios":"Calling vignette({mode: 'Colour'}) (wrong case), vignette({mode: 'soft'}), vignette({mode: 1}), or passing a variable holding an unexpected string. The check is skipped only when mode is undefined (defaults apply).","commonSituations":"Case typos (\"Color\", \"COLOR\"); copying a mode name from another library; data-driven mode values coming from an API or config without validation; renaming the variant and missing a call site.","solutions":["Use exactly \"color\" or \"alpha\", or omit mode to accept the default.","If the value is dynamic, validate it against ['color','alpha'] before passing it.","Search the codebase for the misspelled value and correct the source.","Add a TypeScript literal union for mode so the compiler rejects invalid values at build time."],"exampleFix":"// before\nimport {vignette} from '@remotion/effects';\n\nconst e = vignette({mode: 'Colour', amount: 0.6}); // throws TypeError\n\n// after\nconst e = vignette({mode: 'color', amount: 0.6});\n// or omit for the default\nconst e2 = vignette({amount: 0.6});","handlingStrategy":"validation","validationCode":"import {vignette} from '@remotion/effects';\n\nconst VIGNETTE_MODES = ['color', 'alpha'] as const;\ntype VignetteMode = (typeof VIGNETTE_MODES)[number];\n\nconst assertMode = (mode: unknown): VignetteMode | undefined => {\n  if (mode === undefined) return undefined;\n  if (!VIGNETTE_MODES.includes(mode as VignetteMode)) {\n    throw new TypeError(`mode must be one of ${VIGNETTE_MODES.join('|')}, got ${JSON.stringify(mode)}`);\n  }\n  return mode as VignetteMode;\n};\n\nconst mode = assertMode(config.mode); // throws before vignette() is called\nconst e = vignette({mode, amount: 0.6});","typeGuard":"const VIGNETTE_MODES = ['color', 'alpha'] as const;\ntype VignetteMode = (typeof VIGNETTE_MODES)[number];\nconst isVignetteMode = (v: unknown): v is VignetteMode =>\n  typeof v === 'string' && (VIGNETTE_MODES as readonly string[]).includes(v);","tryCatchPattern":"try {\n  const e = vignette({mode: config.mode, amount: 0.6});\n} catch (err) {\n  if (err instanceof TypeError) {\n    console.error('Invalid vignette mode:', config.mode, err);\n  }\n  throw err;\n}","preventionTips":["Type mode as the literal union 'color' | 'alpha' so invalid values fail at compile time.","Validate dynamic/API-supplied mode against the allowed set before calling vignette().","Avoid deriving mode from free-form user input without a whitelist.","Run typecheck in CI to catch misspelled literals."],"tags":["validation","params","vignette","typescript"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}