{"record":{"id":"86597df52d656c8f","repo":"framework7io/framework7","slug":"unsupported-variant-variant","errorCode":null,"errorMessage":"Unsupported variant: ${variant}","messagePattern":"Unsupported variant: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/core/shared/material-color-utils.js","lineNumber":2400,"sourceCode":"      return TonalPalette.fromHueAndChroma(sourceColorHct.hue, 0);\n\n     case Variant.NEUTRAL:\n      return TonalPalette.fromHueAndChroma(sourceColorHct.hue, 12);\n\n     case Variant.RAINBOW:\n      return TonalPalette.fromHueAndChroma(sourceColorHct.hue, 48);\n\n     case Variant.TONAL_SPOT:\n      return TonalPalette.fromHueAndChroma(sourceColorHct.hue, 36);\n\n     case Variant.EXPRESSIVE:\n      return TonalPalette.fromHueAndChroma(sanitizeDegreesDouble(sourceColorHct.hue + 240), 40);\n\n     case Variant.VIBRANT:\n      return TonalPalette.fromHueAndChroma(sourceColorHct.hue, 200);\n\n     default:\n      throw new Error(`Unsupported variant: ${variant}`);\n    }\n  }\n  getSecondaryPalette(variant, sourceColorHct, isDark, platform, contrastLevel) {\n    switch (variant) {\n     case Variant.CONTENT:\n     case Variant.FIDELITY:\n      return TonalPalette.fromHueAndChroma(sourceColorHct.hue, Math.max(sourceColorHct.chroma - 32, .5 * sourceColorHct.chroma));\n\n     case Variant.FRUIT_SALAD:\n      return TonalPalette.fromHueAndChroma(sanitizeDegreesDouble(sourceColorHct.hue - 50), 36);\n\n     case Variant.MONOCHROME:\n      return TonalPalette.fromHueAndChroma(sourceColorHct.hue, 0);\n\n     case Variant.NEUTRAL:\n      return TonalPalette.fromHueAndChroma(sourceColorHct.hue, 8);\n\n     case Variant.RAINBOW:","sourceCodeStart":2382,"sourceCodeEnd":2418,"githubUrl":"https://github.com/framework7io/framework7/blob/655759126686766530a027b2f8f369c991d63d1c/src/core/shared/material-color-utils.js#L2382-L2418","documentation":"`getPrimaryPalette` maps each supported Variant (CONTENT, FIDELITY, VIBRANT, EXPRESSIVE, etc.) to a TonalPalette construction. Any variant value outside the switch cases falls to `default` and throws this error. It signals that an unrecognized or unsupported Variant enum value was passed into palette construction.","triggerScenarios":"Calling `getPrimaryPalette(variant, ...)` (directly or via a DynamicScheme) with a variant not handled by the switch — e.g. an out-of-range number, undefined/null, or a 2025-only variant like EXPRESSIVE/VIBRANT passed where unsupported.","commonSituations":"Typo'd or hand-rolled variant constants; deserializing a saved theme whose variant enum value changed between library versions; forwarding user config into DynamicScheme without validating the variant.","solutions":["Log/inspect the incoming variant value and map it to a valid Variant enum member before calling.","Use `Variant.VIBRANT` or another documented Variant constant instead of raw numbers/strings.","If a 2025-only variant is needed, ensure the 2025 palette delegate/scheme is used rather than the 2021 one.","Add a default fallback variant when parsing user-supplied theme config."],"exampleFix":"// before\nconst palette = getPrimaryPalette(theme.variant, hct, dark, platform, contrast); // theme.variant = 'vibrant' (string)\n// after\nconst variant = Variant[theme.variant] ?? Variant.TONAL_SPOT; // coerce to enum with fallback\nconst palette = getPrimaryPalette(variant, hct, dark, platform, contrast);","handlingStrategy":"validation","validationCode":"const VALID_VARIANTS = new Set(Object.values(Variant));\nfunction assertValidVariant(v) {\n  if (!VALID_VARIANTS.has(v)) throw new RangeError(`variant must be a Variant enum value, got ${v}`);\n}\nassertValidVariant(variant); // before getPrimaryPalette","typeGuard":"const isValidVariant = (v) => v != null && Object.values(Variant).includes(v);","tryCatchPattern":"let palette;\ntry {\n  palette = getPrimaryPalette(variant, hct, dark, platform, contrast);\n} catch (e) {\n  if (e.message.startsWith('Unsupported variant')) {\n    console.warn('Unknown variant, falling back to TONAL_SPOT', variant);\n    palette = getPrimaryPalette(Variant.TONAL_SPOT, hct, dark, platform, contrast);\n  } else throw e;\n}","preventionTips":["Always use Variant enum constants, never raw numbers or strings.","Validate theme config variant fields at parse time.","When upgrading the library, re-map persisted variant ids against the new enum.","Default unknown variants to TONAL_SPOT at the config boundary."],"tags":["material-color","invalid-enum","variant"],"backgroundTag":"invalid-enum-value","analyzedSha":"655759126686766530a027b2f8f369c991d63d1c","analyzedAt":"2026-09-02T19:48:40.711Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-10T02:17:09.455Z"}