{"record":{"id":"c916846d052dd3e2","repo":"shadcn-ui/ui","slug":"unauthorized","errorCode":"UNAUTHORIZED","errorMessage":"You are not authorized to access the item at ${url}. If this is a remote registry, you may need to authenticate.","messagePattern":"You are not authorized to access the item at (.+?)\\. If this is a remote registry, you may need to authenticate\\.","errorType":"http","errorClass":"RegistryUnauthorizedError","httpStatus":401,"severity":"error","filePath":"packages/shadcn/src/registry/fetcher.ts","lineNumber":91,"sourceCode":"                  title: z.string().optional(),\n                  // Standard error response.\n                  message: z.string().optional(),\n                  error: z.string().optional(),\n                })\n                .safeParse(json)\n\n              if (parsed.success) {\n                // Prefer RFC 7807 detail field, then message field.\n                messageFromServer = parsed.data.detail || parsed.data.message\n\n                if (parsed.data.error) {\n                  messageFromServer = `[${parsed.data.error}] ${messageFromServer}`\n                }\n              }\n            }\n\n            if (response.status === 401) {\n              throw new RegistryUnauthorizedError(url, messageFromServer)\n            }\n\n            if (response.status === 404) {\n              throw new RegistryNotFoundError(url, messageFromServer)\n            }\n\n            if (response.status === 410) {\n              throw new RegistryGoneError(url, messageFromServer)\n            }\n\n            if (response.status === 403) {\n              throw new RegistryForbiddenError(url, messageFromServer)\n            }\n\n            throw new RegistryFetchError(\n              url,\n              response.status,\n              messageFromServer","sourceCodeStart":73,"sourceCodeEnd":109,"githubUrl":"https://github.com/shadcn-ui/ui/blob/efac5987074af84ece57c367c6dd83387b967022/packages/shadcn/src/registry/fetcher.ts#L73-L109","documentation":"Thrown by fetchRegistry when the registry endpoint responds with HTTP 401. RegistryUnauthorizedError signals that authentication is required and was not provided (or was invalid). The server's RFC 7807 detail/message, if any, is captured as the cause for display.","triggerScenarios":"Fetching an item or catalog from a private/authenticated registry without sending the required Authorization header, with an expired token, or with credentials for the wrong account.","commonSituations":"Custom registry requires a bearer token but the header was not configured in components.json, an env var referenced by the header is unset/empty, or the token was revoked.","solutions":["Configure the registry's auth header in components.json: \"@myorg\": { \"url\": \"...\", \"headers\": { \"Authorization\": \"Bearer ${REGISTRY_TOKEN}\" } }.","Export the referenced env var (e.g. REGISTRY_TOKEN) in your shell or .env.","Confirm the token is still valid and has not expired.","If the registry uses a different scheme (basic, cookie), set the matching header."],"exampleFix":"// before: components.json\n{\n  \"registries\": {\n    \"@myorg\": \"https://priv.example.com/r/{name}.json\"\n  }\n}\n\n// after\n{\n  \"registries\": {\n    \"@myorg\": {\n      \"url\": \"https://priv.example.com/r/{name}.json\",\n      \"headers\": { \"Authorization\": \"Bearer ${REGISTRY_TOKEN}\" }\n    }\n  }\n}","handlingStrategy":"validation","validationCode":"function ensureAuthHeaders(registryConfig: { headers?: Record<string,string> }, requiredVars: string[]) {\n  for (const v of requiredVars) {\n    if (!process.env[v]) {\n      throw new Error(`Missing env var ${v} required for registry auth.`);\n    }\n  }\n  return registryConfig;\n}","typeGuard":"function hasAuthHeader(headers?: Record<string,string>): boolean {\n  if (!headers) return false;\n  const keys = Object.keys(headers).map(k => k.toLowerCase());\n  return keys.includes(\"authorization\") || keys.includes(\"cookie\") || keys.includes(\"x-api-key\");\n}","tryCatchPattern":"try {\n  await fetchRegistry([url]);\n} catch (err) {\n  if (err instanceof RegistryUnauthorizedError) {\n    // prompt user to set REGISTRY_TOKEN, then retry once\n  }\n  throw err;\n}","preventionTips":["Define auth headers via env-var templating so tokens never sit in config files.","Verify referenced env vars are exported in the shell/CI before running.","Rotate tokens and confirm scope before deploy."],"tags":["network","auth","unauthorized","registry","typescript"],"backgroundTag":null,"analyzedSha":"efac5987074af84ece57c367c6dd83387b967022","analyzedAt":"2026-08-12T05:00:50.218Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}