{"record":{"id":"eff9190611d32235","repo":"shadcn-ui/ui","slug":"failed-to-fetch-registry-item-response-statuste","errorCode":null,"errorMessage":"Failed to fetch registry item: ${response.statusText}","messagePattern":"Failed to fetch registry item: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"apps/v4/app/(app)/(create)/lib/v0.ts","lineNumber":583,"sourceCode":"      components: \"./components\",\n      lib: \"./lib\",\n      hooks: \"./hooks\",\n      ui: \"./components/ui\",\n    },\n  } satisfies z.infer<typeof configSchema>\n}\n\nasync function getRegistryItemFile(\n  name: string,\n  designSystemConfig: DesignSystemConfig,\n  config: z.infer<typeof configSchema>\n) {\n  const response = await fetch(\n    `${process.env.NEXT_PUBLIC_APP_URL}/r/styles/${getStyle(designSystemConfig)}/${name}.json`\n  )\n\n  if (!response.ok) {\n    throw new Error(`Failed to fetch registry item: ${response.statusText}`)\n  }\n\n  const json = await response.json()\n  const item = registryItemSchema.parse(json)\n\n  const file = item.files?.[0]\n  if (!file?.content) {\n    return null\n  }\n\n  const content = await transformFileContent(file.content, config)\n\n  return {\n    ...file,\n    target:\n      name === \"example\"\n        ? \"components/example.tsx\"\n        : `components/ui/${name}.tsx`,","sourceCodeStart":565,"sourceCodeEnd":601,"githubUrl":"https://github.com/shadcn-ui/ui/blob/efac5987074af84ece57c367c6dd83387b967022/apps/v4/app/(app)/(create)/lib/v0.ts#L565-L601","documentation":"getRegistryItemFile() fetches a component JSON from `${NEXT_PUBLIC_APP_URL}/r/styles/<style>/<name>.json` and throws when the response is not ok, surfacing response.statusText. It is the network boundary for pulling per-component registry files during v0 payload generation.","triggerScenarios":"NEXT_PUBLIC_APP_URL unset or wrong so the fetch hits a non-existent host or path; the Next.js dev server not running; the requested component name does not exist for the given style (404); a proxy or gateway returning 5xx.","commonSituations":"Local dev with a misconfigured environment variable; deploying without setting NEXT_PUBLIC_APP_URL; referencing a component removed from the registry; transient network blips.","solutions":["Ensure NEXT_PUBLIC_APP_URL is set and reachable (e.g. http://localhost:3000) and that the Next.js dev server is up.","Confirm the component <name> exists under /r/styles/<base>-<style>/ in the registry.","On 404, treat the component as unavailable and skip it instead of throwing.","Add a retry with backoff for transient non-4xx failures."],"exampleFix":"// before\nconst response = await fetch(`${process.env.NEXT_PUBLIC_APP_URL}/r/styles/${style}/${name}.json`)\nif (!response.ok) throw new Error(`Failed to fetch registry item: ${response.statusText}`)\n\n// after\nif (!process.env.NEXT_PUBLIC_APP_URL) throw new Error(\"NEXT_PUBLIC_APP_URL is not set\")\nconst response = await fetch(url)\nif (response.status === 404) return null // component unavailable\nif (!response.ok) throw new Error(`Failed to fetch registry item: ${response.statusText}`)","handlingStrategy":"retry","validationCode":"if (!process.env.NEXT_PUBLIC_APP_URL) {\n  throw new Error(\"NEXT_PUBLIC_APP_URL must be set to fetch registry items\")\n}\nconst probe = await fetch(\n  `${process.env.NEXT_PUBLIC_APP_URL}/r/styles/${style}/${name}.json`,\n  { method: \"HEAD\" }\n)\nif (!probe.ok) {\n  // skip or fallback before calling getRegistryItemFile\n}","typeGuard":null,"tryCatchPattern":"try {\n  const file = await getRegistryItemFile(name, config, cfg)\n} catch (e) {\n  if (/Failed to fetch registry item/.test((e as Error).message)) {\n    // log, retry once for transient failures, or degrade gracefully\n  } else throw e\n}","preventionTips":["Set NEXT_PUBLIC_APP_URL in all environments (dev, preview, prod).","Health-check the /r route on deploy.","Cache registry items to survive transient outages."],"tags":["network","registry","fetch","environment","v0"],"backgroundTag":null,"analyzedSha":"efac5987074af84ece57c367c6dd83387b967022","analyzedAt":"2026-08-12T05:00:50.218Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}