{"record":{"id":"406e522158c9f176","repo":"shadcn-ui/ui","slug":"fetch-error-406e52","errorCode":"FETCH_ERROR","errorMessage":"Failed to read GitHub source file \"${filePath}\" from ${formatGitHubSource(address)}.","messagePattern":"Failed to read GitHub source file \"(.+?)\" from (.+?)\\.","errorType":"error_code","errorClass":"RegistrySourceFileError","httpStatus":null,"severity":"error","filePath":"packages/shadcn/src/registry/github.ts","lineNumber":187,"sourceCode":"    },\n  }\n}\n\nasync function fetchGitHubSourceFile(\n  url: string,\n  filePath: string,\n  address: GitHubSource\n) {\n  let response: Response\n  try {\n    response = await fetchWithProxy(url, {\n      headers: new Headers({\n        \"Accept-Encoding\": \"identity\",\n        \"User-Agent\": \"shadcn\",\n      }),\n    })\n  } catch (error) {\n    throw new RegistrySourceFileError(filePath, error, {\n      message: `Failed to read GitHub source file \"${filePath}\" from ${formatGitHubSource(\n        address\n      )}.`,\n      context: {\n        reason: \"github-source-file\",\n        url,\n        source: formatGitHubSource(address),\n        filePath,\n      },\n      suggestion:\n        \"GitHub ref resolution succeeded, but the CLI could not fetch from raw.githubusercontent.com. Check that raw.githubusercontent.com is accessible from this network.\",\n    })\n  }\n\n  if (!response.ok) {\n    throw new RegistrySourceFileError(filePath, undefined, {\n      message: `Failed to read GitHub source file \"${filePath}\" from ${formatGitHubSource(\n        address","sourceCodeStart":169,"sourceCodeEnd":205,"githubUrl":"https://github.com/shadcn-ui/ui/blob/efac5987074af84ece57c367c6dd83387b967022/packages/shadcn/src/registry/github.ts#L169-L205","documentation":"Thrown by fetchGitHubSourceFile in the try/catch around fetchWithProxy: the network request to raw.githubusercontent.com itself threw (connection refused, DNS failure, TLS error, timeout, or proxy error). GitHub ref resolution already succeeded; only the raw-file fetch failed. The error is wrapped as RegistrySourceFileError with the offending url, source, and filePath in context.","triggerScenarios":"Corporate firewall or egress proxy blocks raw.githubusercontent.com, DNS resolution fails in a sandboxed CI, TLS interception breaks the handshake, or the network is offline after the (cached) ref resolution step.","commonSituations":"CI runners behind a restrictive proxy, air-gapped environments, intermittent connectivity, or a proxy env var (HTTPS_PROXY) pointing at an unreachable proxy.","solutions":["Verify raw.githubusercontent.com is reachable: curl -I the URL from the same environment.","Correct or clear the HTTPS_PROXY/HTTP_PROXY env vars if the configured proxy is unreachable.","Whitelist raw.githubusercontent.com on the firewall/proxy.","Retry once network is restored; ref resolution results are cached so only the file fetch is repeated."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"async function rawGithubReachable(url: string) {\n  const res = await fetch(url, { method: \"HEAD\" });\n  if (!res.ok && res.status >= 500) throw new Error(`raw.githubusercontent.com unhealthy (${res.status})`);\n  return true;\n}\n// probe reachability before kicking off a build that resolves GitHub sources","typeGuard":"function isNetworkError(err: unknown): boolean {\n  return err instanceof RegistrySourceFileError && err.context?.reason === \"github-source-file\" && err.context?.statusCode === undefined;\n}","tryCatchPattern":"for (const wait of [0, 2000, 8000]) {\n  try {\n    return await fetchGitHubRegistryItem(address);\n  } catch (err) {\n    if (err instanceof RegistrySourceFileError && err.context?.reason === \"github-source-file\" && err.context?.statusCode === undefined && wait < 8000) {\n      await new Promise(r => setTimeout(r, wait));\n      continue;\n    }\n    throw err;\n  }\n}","preventionTips":["Ensure HTTPS_PROXY is set correctly (or unset) in CI before resolving GitHub sources.","Whitelist raw.githubusercontent.com on corporate egress proxies.","Cache resolved SHAs so transient network issues only repeat the raw-file fetch."],"tags":["network","github","proxy","fetch-error","typescript"],"backgroundTag":null,"analyzedSha":"efac5987074af84ece57c367c6dd83387b967022","analyzedAt":"2026-08-12T05:00:50.218Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}