{"record":{"id":"a8b02db0b5533bad","repo":"shadcn-ui/ui","slug":"invalid-config-a8b02d","errorCode":"INVALID_CONFIG","errorMessage":"Invalid ${configName} configuration in ${cwd}.","messagePattern":"Invalid (.+?) configuration in (.+?)\\.","errorType":"validation","errorClass":"ConfigParseError","httpStatus":null,"severity":"error","filePath":"packages/shadcn/src/registry/api.ts","lineNumber":265,"sourceCode":"      },\n      \"package.json\"\n    )\n  }\n\n  return {\n    registries: {},\n  }\n}\n\nfunction parseRegistriesConfig(\n  cwd: string,\n  config: unknown,\n  configFile: \"components.json\" | \"package.json\"\n) {\n  const result = registriesConfigFileSchema.safeParse(config)\n\n  if (!result.success) {\n    throw new ConfigParseError(cwd, result.error, configFile)\n  }\n\n  return {\n    registries: result.data.registries || {},\n  }\n}\n\nexport async function getShadcnRegistryIndex() {\n  const [result] = await fetchRegistry([\"index.json\"])\n\n  return registryIndexSchema.parse(result)\n}\n\nexport async function getRegistryStyles() {\n  try {\n    const [result] = await fetchRegistry([\"styles/index.json\"])\n\n    return stylesSchema.parse(result)","sourceCodeStart":247,"sourceCodeEnd":283,"githubUrl":"https://github.com/shadcn-ui/ui/blob/efac5987074af84ece57c367c6dd83387b967022/packages/shadcn/src/registry/api.ts#L247-L283","documentation":"Thrown by parseRegistriesConfig when registriesConfigFileSchema.safeParse(config) fails while loading the 'registries' block from either components.json or package.json. The ConfigParseError names which config file failed and embeds the ZodError issues so the offending field is visible.","triggerScenarios":"A components.json with a malformed 'registries' object (e.g., a registry value that is neither a string nor a valid {url,headers,params} object), or a package.json whose top-level 'registries' field has the wrong shape. Also triggered by passing an explicitly loaded config whose registries entries fail registryConfigSchema.","commonSituations":"Editing components.json by hand and using a non-string header value, forgetting the 'url' key in an object-form registry entry, or JSON syntax errors in the registries block. Migrating config format between versions.","solutions":["Read the printed ZodError issues to find the exact failing path under 'registries'.","Ensure each entry is either a URL string or an object with a string 'url' (and optional string 'headers'/'params').","Run 'npx shadcn@latest init' to regenerate a known-good components.json.","Validate the file with a JSON linter before saving."],"exampleFix":"// before: components.json\n{\n  \"registries\": {\n    \"@myorg\": { \"url\": 123 }\n  }\n}\n\n// after\n{\n  \"registries\": {\n    \"@myorg\": { \"url\": \"https://example.com/r/{name}.json\" }\n  }\n}","handlingStrategy":"validation","validationCode":"import { registryConfigSchema } from \"@/src/schema\";\n\nfunction validateRegistriesConfig(config: unknown) {\n  const result = z.object({ registries: registryConfigSchema.optional() })\n    .safeParse(config);\n  if (!result.success) {\n    throw new Error(`components.json registries invalid: ${result.error.message}`);\n  }\n  return result.data;\n}","typeGuard":"function isValidRegistriesBlock(config: unknown): boolean {\n  return z.object({ registries: registryConfigSchema.optional() })\n    .safeParse(config).success;\n}","tryCatchPattern":"try {\n  await getRegistriesConfig(cwd);\n} catch (err) {\n  if (err instanceof ConfigParseError) {\n    // err.cause is the ZodError; show its issues, then offer to run `shadcn init`\n  }\n  throw err;\n}","preventionTips":["Lint components.json as JSON before committing.","Use object form for registries with headers/params; never mix types in values.","Re-run 'npx shadcn@latest init' after a CLI upgrade to regenerate valid config."],"tags":["config","components-json","validation","zod","typescript"],"backgroundTag":null,"analyzedSha":"efac5987074af84ece57c367c6dd83387b967022","analyzedAt":"2026-08-12T05:00:50.218Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}