{"record":{"id":"9bb696c83d5ccb94","repo":"shadcn-ui/ui","slug":"parse-error-9bb696","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/loader.ts","lineNumber":408,"sourceCode":"async function readRegistryJson(registryFile: string) {\n  try {\n    return await fs.readFile(registryFile, \"utf-8\")\n  } catch (error) {\n    throw new RegistryLocalFileError(registryFile, error, {\n      message: `Failed to read registry file at ${registryFile}.`,\n      context: { registryFile },\n      suggestion:\n        \"Check that the registry.json file exists and that the 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":390,"sourceCodeEnd":426,"githubUrl":"https://github.com/shadcn-ui/ui/blob/efac5987074af84ece57c367c6dd83387b967022/packages/shadcn/src/registry/loader.ts#L390-L426","documentation":"Thrown by parseRegistry when JSON.parse rejects the registry file contents. This is a syntax-level failure (malformed JSON), distinct from error 87 which is a schema failure. The original parse error is attached as cause. The library treats any unparseable registry as fatal because no downstream validation can proceed.","triggerScenarios":"A registry.json that is not valid JSON: trailing commas, single quotes, unquoted keys, comments, control characters, or a truncated file. JSON.parse(content) throws and the catch wraps it into RegistryParseError with code PARSE_ERROR.","commonSituations":"Hand-editing registry.json and leaving a trailing comma or comment. File truncated by a failed write or git conflict markers left in. Copy-pasting from a JS/TS source that used unquoted keys. A build tool that emitted JSON5. Editor inserting a BOM or smart quotes.","solutions":["Open the registryFile shown in the error and run it through a JSON validator (e.g. JSON.parse in a REPL, or a linter).","Remove trailing commas, comments, and single quotes; quote all keys.","Resolve git merge conflicts fully (no >>> ==== <<< markers).","Re-serialize the file from a known-good object (JSON.stringify(obj, null, 2))."],"exampleFix":"// before - invalid JSON\n{\n  \"name\": \"my-registry\",\n  \"homepage\": \"https://example.com\",  // trailing comma\n  \"items\": [\n    { \"name\": \"button\", }\n  ]\n}\n\n// after\n{\n  \"name\": \"my-registry\",\n  \"homepage\": \"https://example.com\",\n  \"items\": [\n    { \"name\": \"button\" }\n  ]\n}","handlingStrategy":"validation","validationCode":"function assertValidJson(content: string, file: string) {\n  try {\n    JSON.parse(content)\n  } catch (e) {\n    throw new Error(`${file} is not valid JSON: ${(e as Error).message}`)\n  }\n}\n\n// before loadRegistry:\nassertValidJson(await fs.readFile(registryFile, \"utf-8\"), registryFile)","typeGuard":null,"tryCatchPattern":"try {\n  await loadRegistry({ registryFile })\n} catch (err) {\n  if (err instanceof RegistryParseError) {\n    // err.cause is the original SyntaxError; fix the JSON\n  }\n  throw err\n}","preventionTips":["Use an editor with JSON linting.","Validate registry.json in CI with a JSON parser before build.","Avoid hand-editing; regenerate from a source object."],"tags":["registry","json","parse","syntax"],"backgroundTag":null,"analyzedSha":"efac5987074af84ece57c367c6dd83387b967022","analyzedAt":"2026-08-12T05:00:50.218Z","schemaVersion":2},"datasetVersion":"2026-08-12T12:31:55.035Z"}