shadcn-ui/ui · error · Error

Invalid registry schema for ${style.name}

Error message

Invalid registry schema for ${style.name}

What it means

registrySchema.safeParse guard in the per-style index build path: for each style, the script imports its registry (from the base combination for generated styles, or registry/<style>/registry.ts for legacy styles), parses it, and on failure logs the formatted Zod error and throws 'Invalid registry schema for <style>'.

Source

Thrown at apps/v4/scripts/build-registry.mts:1250

import "server-only"

export const Index: Record<string, Record<string, any>> = {`

  const componentShards: ComponentShard[] = []

  for (const style of styles) {
    const styleCombination = getStyleCombination(style.name)
    const { registry: importedRegistry } = styleCombination
      ? await import(
          `../registry/bases/${styleCombination.base.name}/registry.ts`
        )
      : await import(`../registry/${style.name}/registry.ts`)

    const parseResult = registrySchema.safeParse(importedRegistry)
    if (!parseResult.success) {
      console.error(`❌ Registry validation failed for ${style.name}:`)
      console.error(parseResult.error.format())
      throw new Error(`Invalid registry schema for ${style.name}`)
    }

    const registry = parseResult.data

    index += `
  "${style.name}": {`
    const shard: ComponentShard = { key: style.name, entries: "", names: [] }

    for (const item of registry.items) {
      if (item.type === "registry:internal") {
        continue
      }

      if (styleCombination && !shouldIncludeStyledRegistryItem(item)) {
        continue
      }

      const files = normalizeRegistryFiles(item)

View on GitHub (pinned to efac598707)

Solutions

  1. Read the 'Registry validation failed for <style>' block above the throw for the exact Zod issue.
  2. Fix the offending item in the style's registry.ts (or its base for generated combos).
  3. Validate with registrySchema.parse locally before running the index build.

Example fix

// before
{ type: "registry:ui", files: ["ui/card.tsx"] } // missing name

// after
{ name: "card", type: "registry:ui", files: ["ui/card.tsx"] }
Defensive patterns

Strategy: validation

Validate before calling

import { registrySchema } from "shadcn/schema"
for (const style of getStylesToBuild()) {
  const { registry } = styleCombination
    ? await import(`../registry/bases/${styleCombination.base.name}/registry.ts`)
    : await import(`../registry/${style.name}/registry.ts`)
  const r = registrySchema.safeParse(registry)
  if (!r.success) throw new Error(`${style.name}: ${JSON.stringify(r.error.format())}`)
}

Type guard

function isValidStyleRegistry(value: unknown): boolean {
  return registrySchema.safeParse(value).success
}

Prevention

When it happens

Trigger: A legacy style's registry.ts violating registrySchema; a generated combination's base registry failing validation surfaced when building that style's index; wrong item shape/type/files.

Common situations: Editing a legacy style registry; schema tightened in shadcn/schema; new item added without a required field.

Related errors


AI-assisted analysis of shadcn-ui/ui@efac598707 (2026-08-12). Data as JSON: /api/errors/a076739f2d098ced. Report an issue: GitHub.