{"record":{"id":"230ad6d1d6984156","repo":"shadcn-ui/ui","slug":"parse-error-230ad6","errorCode":"PARSE_ERROR","errorMessage":"Failed to parse registry file: ${registryFile}","messagePattern":"Failed to parse registry file: (.+?)","errorType":"exception","errorClass":"RegistryParseError","httpStatus":null,"severity":"error","filePath":"packages/shadcn/src/registry/source.ts","lineNumber":407,"sourceCode":"      message: `Failed to read source registry file at ${formatSourcePath(\n        registryFile,\n        options.source\n      )}.`,\n      context: { registryFile, source: options.source },\n      suggestion:\n        registryFile === \"registry.json\"\n          ? \"Check that the repository has a registry.json file at its root.\"\n          : \"Check that the included registry.json file exists and that the include path is correct.\",\n    })\n  }\n}\n\nfunction parseRegistry(content: string, registryFile: string) {\n  let json: unknown\n  try {\n    json = JSON.parse(content)\n  } catch (error) {\n    throw new RegistryParseError(registryFile, error, {\n      subject: \"registry file\",\n      context: { registryFile },\n      suggestion:\n        \"Fix the JSON syntax in the registry.json file and try again.\",\n    })\n  }\n\n  const result = registryChunkSchema.safeParse(json)\n  if (!result.success) {\n    throw new RegistryValidationError(\n      `Invalid registry file at ${registryFile}:\\n${formatZodIssues(\n        result.error\n      )}`,\n      {\n        registryFile,\n        cause: result.error,\n        suggestion:\n          \"Update the registry.json file so it matches the registry schema.\",","sourceCodeStart":389,"sourceCodeEnd":425,"githubUrl":"https://github.com/shadcn-ui/ui/blob/efac5987074af84ece57c367c6dd83387b967022/packages/shadcn/src/registry/source.ts#L389-L425","documentation":"Thrown by parseRegistry when JSON.parse(content) throws — the registry file content is not syntactically valid JSON. This is purely a JSON-syntax failure (trailing comma, unquoted key, stray comment, BOM/encoding issue). It is distinct from error 114, which fires when the JSON parses but fails the registry chunk Zod schema. The error is a RegistryParseError with subject 'registry file' and a 'fix the JSON syntax' suggestion.","triggerScenarios":"A hand-edited registry.json with a trailing comma, single-quoted string, JS-style comment, or unquoted key; a file with a BOM or mixed encoding; HTML returned instead of JSON in non-source contexts.","commonSituations":"Manual editing of registry.json without a JSON linter; copy-pasting config snippets that include `//` comments; CRLF/encoding issues from cross-platform editing.","solutions":["Run the file through a JSON linter or `node -e 'JSON.parse(require(\"fs\").readFileSync(\"registry.json\",\"utf8\"))'` to locate the syntax error.","Remove comments, trailing commas, and unquoted keys.","Re-save with UTF-8 (no BOM) encoding."],"exampleFix":"// before — registry.json with trailing comma (invalid JSON)\n{\n  \"name\": \"my-registry\",\n  \"homepage\": \"https://my.dev\",\n  \"items\": [],\n}\n\n// after — trailing comma removed\n{\n  \"name\": \"my-registry\",\n  \"homepage\": \"https://my.dev\",\n  \"items\": []\n}","handlingStrategy":"validation","validationCode":"function isValidJson(content: string): { ok: true; value: unknown } | { ok: false; error: unknown } {\n  try {\n    return { ok: true, value: JSON.parse(content) };\n  } catch (e) {\n    return { ok: false, error: e };\n  }\n}","typeGuard":null,"tryCatchPattern":"import { RegistryParseError } from \"@/src/registry/errors\";\n\ntry {\n  await loadRegistryItemFromSource(name, reader, opts);\n} catch (e) {\n  if (e instanceof RegistryParseError && /registry file/i.test(e.message)) {\n    // JSON syntax error; lint the file at e.context.registryFile\n  }\n  throw e;\n}","preventionTips":["Use a JSON-aware editor with syntax checking enabled.","Run a JSON linter (e.g. `jsonlint`) on registry.json in CI.","Never add comments or trailing commas to registry.json."],"tags":["registry","json","parse","validation"],"backgroundTag":null,"analyzedSha":"efac5987074af84ece57c367c6dd83387b967022","analyzedAt":"2026-08-12T05:00:50.218Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}