shadcn-ui/ui · error · Error

Invalid registry schema for ${base.name}

Error message

Invalid registry schema for ${base.name}

What it means

During the base index build, each base's imported registry.ts is validated with registrySchema.safeParse (from shadcn/schema). If the parsed object does not conform — wrong item shape, missing name, bad type enum, malformed files/dependencies/categories — safeParse returns failure; the script logs the formatted Zod error and rethrows as a generic 'Invalid registry schema for <base>'. This variant runs in the base-index path (buildBaseIndex).

Source

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

      return { base, importedRegistry }
    })
  )

  let index = `// @ts-nocheck
// This file is autogenerated by scripts/build-registry.ts
// Do not edit this file directly.
import "server-only"

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

  const componentShards: ComponentShard[] = []

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

    const registry = parseResult.data

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

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

      const files = normalizeRegistryFiles(item)

      if (files.length === 0) {
        continue
      }

View on GitHub (pinned to efac598707)

Solutions

  1. Read the 'Registry validation failed for <base>' block above the throw — it prints the exact Zod path/issue.
  2. Fix the offending field in registry/bases/<base>/registry.ts to match registrySchema.
  3. Run the schema parse locally on the file in a scratch script to iterate fast.

Example fix

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

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

Strategy: validation

Validate before calling

import { registrySchema } from "shadcn/schema"
import { registry } from "../registry/bases/<base>/registry"
const result = registrySchema.safeParse(registry)
if (!result.success) {
  console.error(result.error.format())
  process.exit(1)
}

Type guard

function isValidRegistry(value: unknown): value is { name: string; items: unknown[] } {
  return registrySchema.safeParse(value).success
}

Prevention

When it happens

Trigger: Authoring/editing registry/bases/<base>/registry.ts with an item missing 'name', using an unknown type string, a files entry that is neither string nor {path,type}, or wrong dependencies/categories types; importing a default export that is not a registry object.

Common situations: Hand-editing a registry item and forgetting a required field; upgrading shadcn/schema (tighter validation) without updating authored registries; copy-pasting an item from an older schema version.

Related errors


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