{"record":{"id":"f2a7c4cb50fa67f3","repo":"shadcn-ui/ui","slug":"base-color-basecolorname-or-theme-themenam","errorCode":null,"errorMessage":"Base color \"${baseColorName}\" or theme \"${themeName}\" not found","messagePattern":"Base color \"(.+?)\" or theme \"(.+?)\" not found","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"apps/v4/app/(app)/(create)/lib/merge-theme.ts","lineNumber":10,"sourceCode":"import { registryItemSchema, type RegistryItem } from \"shadcn/schema\"\n\nimport { BASE_COLORS, THEMES } from \"@/registry/config\"\n\nexport function buildTheme(baseColorName: string, themeName: string) {\n  const baseColor = BASE_COLORS.find((c) => c.name === baseColorName)\n  const theme = THEMES.find((t) => t.name === themeName)\n\n  if (!baseColor || !theme) {\n    throw new Error(\n      `Base color \"${baseColorName}\" or theme \"${themeName}\" not found`\n    )\n  }\n\n  const mergedTheme: RegistryItem = {\n    name: `${baseColor.name}-${theme.name}`,\n    title: `${baseColor.title} ${theme.title}`,\n    type: \"registry:theme\",\n    cssVars: {\n      light: {\n        ...baseColor.cssVars?.light,\n        ...theme.cssVars?.light,\n      },\n      dark: {\n        ...baseColor.cssVars?.dark,\n        ...theme.cssVars?.dark,\n      },\n    },","sourceCodeStart":1,"sourceCodeEnd":28,"githubUrl":"https://github.com/shadcn-ui/ui/blob/efac5987074af84ece57c367c6dd83387b967022/apps/v4/app/(app)/(create)/lib/merge-theme.ts#L1-L28","documentation":"buildTheme() in merge-theme.ts merges a base color and a theme into a registry:theme item. It looks each up by name in BASE_COLORS and THEMES (from @/registry/config) and throws if either lookup misses. It is the create-time UI equivalent of registry/config.ts buildRegistryTheme, guarding callers against unregistered names.","triggerScenarios":"Calling buildTheme(baseColorName, themeName) where either name is not exported by registry/base-colors.ts or registry/themes.ts; forwarding unvalidated URL or user input into buildTheme; a registry rename that the caller did not follow.","commonSituations":"Wiring the (create) style builder to new base/theme selectors; case mismatches (registry names are lowercase); presets persisted with now-renamed ids.","solutions":["Verify the base color name exists in BASE_COLORS (registry/base-colors.ts) and the theme name exists in THEMES (registry/themes.ts).","Normalize casing and validate the names against those lists before calling buildTheme.","If a name was renamed in the registry, migrate the caller to the new id."],"exampleFix":"// before\nbuildTheme(\"Zinc\", \"Blue\") // names are case-sensitive; registry uses lowercase\n\n// after\nbuildTheme(\"zinc\", \"blue\")","handlingStrategy":"validation","validationCode":"import { BASE_COLORS, THEMES } from \"@/registry/config\"\nconst baseOk = BASE_COLORS.some((c) => c.name === baseColorName)\nconst themeOk = THEMES.some((t) => t.name === themeName)\nif (!baseOk || !themeOk) {\n  // reject or normalize input before calling buildTheme\n}","typeGuard":"import { BASE_COLORS, THEMES } from \"@/registry/config\"\nconst BASE_NAMES = new Set(BASE_COLORS.map((c) => c.name))\nconst THEME_NAMES = new Set(THEMES.map((t) => t.name))\nconst isKnownBaseColor = (n: string): n is string => BASE_NAMES.has(n)\nconst isKnownTheme = (n: string): n is string => THEME_NAMES.has(n)","tryCatchPattern":"try {\n  const theme = buildTheme(baseColorName, themeName)\n} catch (e) {\n  // surface a user-friendly \"unknown base/theme\" message\n}","preventionTips":["Drive UI selectors from BASE_COLORS and THEMES so only valid names can be picked.","Normalize and validate URL params before forwarding to buildTheme."],"tags":["theme","configuration","registry","validation"],"backgroundTag":null,"analyzedSha":"efac5987074af84ece57c367c6dd83387b967022","analyzedAt":"2026-08-12T05:00:50.218Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}