{"record":{"id":"063358b5d64e51e2","repo":"shadcn-ui/ui","slug":"failed-to-read-github-source-file-filepath-fr","errorCode":null,"errorMessage":"Failed to read GitHub source file \"${filePath}\" from ${formatGitHubSource(address)}. ${guidance.detail}","messagePattern":"Failed to read GitHub source file \"(.+?)\" from (.+?)\\. (.+?)","errorType":"exception","errorClass":"RegistrySourceFileError","httpStatus":null,"severity":"error","filePath":"packages/shadcn/src/registry/github.ts","lineNumber":408,"sourceCode":"        reason: \"github-source-file\",\n        url,\n        statusCode: response.status,\n        source: formatGitHubSource(address),\n        filePath,\n      },\n      suggestion:\n        filePath === \"registry.json\"\n          ? 'The GitHub repository and ref were resolved, but raw.githubusercontent.com did not return a root registry.json file. Check that the public repository has registry.json at its root and that raw.githubusercontent.com is accessible from this network. If this is a private repository, run \"gh auth login\" or set GH_TOKEN to a token with read access.'\n          : \"Check that the file path exists in the public GitHub repository.\",\n    })\n  }\n\n  try {\n    return await readGitHubResponseTextWithLimit(response)\n  } catch (error) {\n    if (error instanceof GitHubTransportError && error.kind === \"oversize\") {\n      const guidance = getGitHubTransportFailureGuidance(error, \"token\")\n      throw new RegistrySourceFileError(filePath, undefined, {\n        message: `Failed to read GitHub source file \"${filePath}\" from ${formatGitHubSource(\n          address\n        )}. ${guidance.detail}`,\n        context: {\n          reason: \"github-source-file\",\n          source: formatGitHubSource(address),\n          filePath,\n        },\n        suggestion: guidance.suggestion,\n      })\n    }\n    throw error\n  }\n}\n\nfunction buildGitHubRawUrl(\n  address: GitHubSource,\n  resolvedSha: string,","sourceCodeStart":390,"sourceCodeEnd":426,"githubUrl":"https://github.com/shadcn-ui/ui/blob/683a5a9b370acdb7785a0529434e6a3b8c7e0441/packages/shadcn/src/registry/github.ts#L390-L426","documentation":"This error is thrown after a successful raw.githubusercontent.com fetch when reading the response body exceeds the library's size limit — readGitHubResponseTextWithLimit raises a GitHubTransportError with kind 'oversize'. The file path, source repo, and size-limit guidance (getGitHubTransportFailureGuidance) are attached to a RegistrySourceFileError with reason 'github-source-file'. It protects the CLI from buffering arbitrarily large files fetched from GitHub raw.","triggerScenarios":"Calling a registry content fetch where ref resolution and the HTTP fetch both succeed, but the registry file (e.g. registry.json or a referenced file) returned by raw.githubusercontent.com is larger than the built-in response size limit, so readGitHubResponseTextWithLimit rejects with an 'oversize' GitHubTransportError.","commonSituations":"A registry.json that grew very large (thousands of components, inlined content, or generated blobs); accidentally pointing the registry at a repo whose registry.json is a build artifact/minified bundle; generated registries that inline base64 or full file contents; hitting the limit right after adding many items to a monorepo registry.","solutions":["Reduce the size of the offending file — split a large registry.json into multiple smaller registry files and reference items across them","Check you resolved the right repo/ref: an oversized file often means you pointed at the wrong repository or a branch containing a generated/bundled registry.json","Remove inlined content (base64 assets, bundled code) from the registry file and reference files by path instead","If you control the consumer, fetch the file yourself with a higher/no limit and pass the parsed content instead of the remote URL","Report/upgrade the library in case a newer version raises the size limit for legitimate large registries"],"exampleFix":"// before: one giant registry.json (multi-MB) -> oversize error\n{ \"items\": [ /* 5,000 components with inlined content */ ] }\n\n// after: split into smaller registries\n// registry.json\n{ \"items\": [{ \"name\": \"ui\", \"registry\": \"./ui-registry.json\" }] }\n// ui-registry.json\n{ \"items\": [ /* smaller subset */ ] }","handlingStrategy":"validation","validationCode":"// Before pointing the registry at a GitHub raw file, check its size via the GitHub API\nasync function assertRegistryFileSize(owner: string, repo: string, ref: string, path: string, maxBytes: number) {\n  const res = await fetch(`https://api.github.com/repos/${owner}/${repo}/contents/${path}?ref=${ref}`, {\n    headers: process.env.GH_TOKEN ? { Authorization: `Bearer ${process.env.GH_TOKEN}` } : {},\n  })\n  if (!res.ok) throw new Error(`Cannot stat ${path}: HTTP ${res.status}`)\n  const { size } = await res.json()\n  if (size > maxBytes) {\n    throw new Error(`${path} is ${size} bytes, exceeding the ${maxBytes}-byte fetch limit`)\n  }\n}","typeGuard":"function isRegistrySourceFileError(e: unknown): e is RegistrySourceFileError {\n  return e instanceof RegistrySourceFileError\n}\nfunction isGitHubSourceFileOversize(e: unknown): boolean {\n  return (\n    isRegistrySourceFileError(e) &&\n    (e.context as any)?.reason === \"github-source-file\" &&\n    /size|large|limit/i.test(e.message)\n  )\n}","tryCatchPattern":"try {\n  const content = await fetchGitHubSourceFile(address, resolvedSha, filePath)\n} catch (error) {\n  if (isRegistrySourceFileError(error) && (error.context as any)?.reason === \"github-source-file\" && /size|large|limit/i.test(error.message)) {\n    // split or trim the registry file, or fetch it out-of-band with a higher limit\n    throw new Error(`Registry file too large: ${filePath}. Split the registry or reduce its size.`)\n  }\n  throw error\n}","preventionTips":["Keep registry.json files small; split big registries into per-category files","Never inline base64 assets or bundled code in registry files","Add a CI check on registry.json size (e.g. fail if > 1 MB) in repos that publish registries","Stabilize refs to SHAs/tags so you never accidentally resolve a branch with a generated oversized file"],"tags":["github","file-size","limit","registry","fetch"],"backgroundTag":"response-body-too-large","analyzedSha":"683a5a9b370acdb7785a0529434e6a3b8c7e0441","analyzedAt":"2026-08-27T14:12:43.753Z","contentChangedAt":"2026-08-27T14:12:43.753Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}