{"record":{"id":"094c394c9db3bbe1","repo":"shadcn-ui/ui","slug":"invalid-registry-schema-for-base-name","errorCode":null,"errorMessage":"Invalid registry schema for ${base.name}","messagePattern":"Invalid registry schema for (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"apps/v4/scripts/build-registry.mts","lineNumber":884,"sourceCode":"      return { base, importedRegistry }\n    })\n  )\n\n  let index = `// @ts-nocheck\n// This file is autogenerated by scripts/build-registry.ts\n// Do not edit this file directly.\nimport \"server-only\"\n\nexport const Index: Record<string, Record<string, any>> = {`\n\n  const componentShards: ComponentShard[] = []\n\n  for (const { base, importedRegistry } of registryImports) {\n    const parseResult = registrySchema.safeParse(importedRegistry)\n    if (!parseResult.success) {\n      console.error(`❌ Registry validation failed for ${base.name}:`)\n      console.error(parseResult.error.format())\n      throw new Error(`Invalid registry schema for ${base.name}`)\n    }\n\n    const registry = parseResult.data\n\n    index += `\n  \"${base.name}\": {`\n    const shard: ComponentShard = { key: base.name, entries: \"\", names: [] }\n\n    for (const item of registry.items) {\n      if (item.type === \"registry:internal\") {\n        continue\n      }\n\n      const files = normalizeRegistryFiles(item)\n\n      if (files.length === 0) {\n        continue\n      }","sourceCodeStart":866,"sourceCodeEnd":902,"githubUrl":"https://github.com/shadcn-ui/ui/blob/efac5987074af84ece57c367c6dd83387b967022/apps/v4/scripts/build-registry.mts#L866-L902","documentation":"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).","triggerScenarios":"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.","commonSituations":"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.","solutions":["Read the 'Registry validation failed for <base>' block above the throw — it prints the exact Zod path/issue.","Fix the offending field in registry/bases/<base>/registry.ts to match registrySchema.","Run the schema parse locally on the file in a scratch script to iterate fast."],"exampleFix":"// before\n{ type: \"registry:ui\", files: [\"ui/button.tsx\"] } // missing name\n\n// after\n{ name: \"button\", type: \"registry:ui\", files: [\"ui/button.tsx\"] }","handlingStrategy":"validation","validationCode":"import { registrySchema } from \"shadcn/schema\"\nimport { registry } from \"../registry/bases/<base>/registry\"\nconst result = registrySchema.safeParse(registry)\nif (!result.success) {\n  console.error(result.error.format())\n  process.exit(1)\n}","typeGuard":"function isValidRegistry(value: unknown): value is { name: string; items: unknown[] } {\n  return registrySchema.safeParse(value).success\n}","tryCatchPattern":null,"preventionTips":["Run registrySchema.parse on every authored registry.ts in CI as a pre-build gate.","After upgrading shadcn/schema, re-validate all base/style registries.","When adding an item, copy a known-good item and change fields rather than writing from scratch.","Treat the printed Zod error path as authoritative — fix the exact field."],"tags":["build","registry","schema","zod"],"backgroundTag":null,"analyzedSha":"efac5987074af84ece57c367c6dd83387b967022","analyzedAt":"2026-08-12T05:00:50.218Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}