{"record":{"id":"d95a9ab038b0a578","repo":"shadcn-ui/ui","slug":"unknown-font-definition-name","errorCode":null,"errorMessage":"Unknown font definition: ${name}","messagePattern":"Unknown font definition: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"apps/v4/app/(app)/(create)/lib/fonts.ts","lineNumber":17,"sourceCode":"import { FONT_DEFINITIONS, type FontName } from \"@/lib/font-definitions\"\n\ntype CreateFont = {\n  family: string\n  import: string\n  previewVariable: string\n  style: {\n    fontFamily: string\n  }\n  variable: string\n}\n\nfunction createFontOption(name: FontName) {\n  const definition = FONT_DEFINITIONS.find((font) => font.name === name)\n\n  if (!definition) {\n    throw new Error(`Unknown font definition: ${name}`)\n  }\n\n  return {\n    name: definition.title,\n    value: definition.name,\n    font: {\n      family: definition.family,\n      import: definition.import,\n      previewVariable: definition.previewVariable,\n      style: {\n        fontFamily: `var(${definition.previewVariable}), ${definition.family}`,\n      },\n      variable: definition.registryVariable,\n    } satisfies CreateFont,\n    type: definition.type,\n  } as const\n}\n","sourceCodeStart":1,"sourceCodeEnd":35,"githubUrl":"https://github.com/shadcn-ui/ui/blob/efac5987074af84ece57c367c6dd83387b967022/apps/v4/app/(app)/(create)/lib/fonts.ts#L1-L35","documentation":"Thrown by createFontOption() when the FontName passed to it has no matching entry in FONT_DEFINITIONS (imported from @/lib/font-definitions). Because the FONTS array is built eagerly by calling createFontOption at module load, an unknown name crashes at import/bundle time rather than at call time. This is always a data-integrity mismatch between the font registry and the FONTS export list.","triggerScenarios":"Adding createFontOption(\"my-font\") to the FONTS array before registering \"my-font\" in FONT_DEFINITIONS; renaming a font in font-definitions.ts but not in fonts.ts (or vice versa); a typo or casing difference in the name string passed to createFontOption.","commonSituations":"Contributing a new font to the v4 style builder; splitting font metadata between font-definitions.ts and fonts.ts; copy-pasting an existing createFontOption line and changing only the name.","solutions":["Open @/lib/font-definitions and confirm the font exists in FONT_DEFINITIONS with a name field that matches exactly (hyphenation and case).","Correct the string passed to createFontOption in fonts.ts to match the registered name.","If adding a genuinely new font, add its full definition to FONT_DEFINITIONS first, then append createFontOption(\"<name>\") to FONTS."],"exampleFix":"// before\ncreateFontOption(\"my-font\") // FONT_DEFINITIONS has no \"my-font\"\n\n// after (option A): use a registered name\ncreateFontOption(\"inter\")\n\n// after (option B): register it first in font-definitions.ts\n//   { name: \"my-font\", title: \"My Font\", family: \"...\", ... }","handlingStrategy":"validation","validationCode":"import { FONT_DEFINITIONS } from \"@/lib/font-definitions\"\nconst registered = new Set(FONT_DEFINITIONS.map((f) => f.name))\nfunction assertFontKnown(name: string) {\n  if (!registered.has(name as never)) {\n    throw new Error(`Unknown font definition: ${name}`)\n  }\n}\n// assertFontKnown(\"my-font\") before createFontOption(\"my-font\")","typeGuard":"import { FONT_DEFINITIONS, type FontName } from \"@/lib/font-definitions\"\nconst KNOWN = new Set(FONT_DEFINITIONS.map((f) => f.name))\nfunction isFontName(name: string): name is FontName {\n  return KNOWN.has(name)\n}","tryCatchPattern":null,"preventionTips":["Keep FONT_DEFINITIONS as the single source of font names; derive the FONTS array from it.","Rely on the typed FontName at call sites so the compiler rejects unknown names.","Run the dev server or build after adding a font to surface import-time throws."],"tags":["fonts","configuration","registry","module-load"],"backgroundTag":null,"analyzedSha":"efac5987074af84ece57c367c6dd83387b967022","analyzedAt":"2026-08-12T05:00:50.218Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}