{"record":{"id":"68a9733f9f2a1f45","repo":"yamadashy/repomix","slug":"github-api-error-response-status-response-st","errorCode":null,"errorMessage":"GitHub API error: ${response.status} ${response.statusText}","messagePattern":"GitHub API error: (.+?) (.+?)","errorType":"http","errorClass":"RepomixError","httpStatus":null,"severity":"error","filePath":"src/core/git/gitHubArchiveApi.ts","lineNumber":66,"sourceCode":"    const rateLimitRemaining = response.headers.get('X-RateLimit-Remaining');\n    if (rateLimitRemaining === '0') {\n      const resetTime = response.headers.get('X-RateLimit-Reset');\n      const resetDate = resetTime ? new Date(Number.parseInt(resetTime, 10) * 1000) : null;\n      throw new RepomixError(\n        `GitHub API rate limit exceeded. ${resetDate ? `Rate limit resets at ${resetDate.toISOString()}` : 'Please try again later.'}`,\n      );\n    }\n    throw new RepomixError(\n      'Access denied. The repository might be private or you might not have permission to access it.',\n    );\n  }\n\n  if (response.status === 500 || response.status === 502 || response.status === 503 || response.status === 504) {\n    throw new RepomixError('GitHub server error. Please try again later.');\n  }\n\n  if (!response.ok) {\n    throw new RepomixError(`GitHub API error: ${response.status} ${response.statusText}`);\n  }\n};\n","sourceCodeStart":48,"sourceCodeEnd":69,"githubUrl":"https://github.com/yamadashy/repomix/blob/f465ad909315a22120636baf03fa5e28701a50cb/src/core/git/gitHubArchiveApi.ts#L48-L69","documentation":"Fallback branch of checkGitHubResponse: any response that is not ok and did not match the earlier 404/403/5xx checks is reported with its raw HTTP status and statusText. It signals an unexpected API condition the library has no specific message for.","triggerScenarios":"The GitHub API/archive endpoint returns any non-2xx status other than 404, 403, and 500/502/503/504 — e.g. 401 (bad token), 422, or an unusual 3xx/4xxsurfacing from proxies or API changes.","commonSituations":"Malformed GITHUB_TOKEN causing 401; API surface changes or deprecations; proxies/gateways injecting their own status codes (e.g. 429 from a corporate rate limiter); GitHub preview/API version mismatches.","solutions":["Read the status code in the message and look it up in GitHub's REST API docs to identify the cause.","If status is 401, replace the invalid/expired GITHUB_TOKEN with a fresh one.","If status is 429, slow down request volume or add a token (a proxy may be rate limiting, not GitHub).","Update repomix to the latest version in case the GitHub API behavior changed and the library handles it."],"exampleFix":"// before (malformed token => 401)\nexport GITHUB_TOKEN=\" \"\n// after\nexport GITHUB_TOKEN=ghp_freshValidToken","handlingStrategy":"try-catch","validationCode":null,"typeGuard":"const isGitHubApiError = (e: unknown): e is RepomixError =>\n  e instanceof RepomixError && /^GitHub API error: \\d{3}/.test(e.message);","tryCatchPattern":"try {\n  await pack({ remote: url });\n} catch (e) {\n  const m = e instanceof RepomixError ? e.message.match(/GitHub API error: (\\d+)/) : null;\n  if (m) {\n    console.error(`Unexpected GitHub status ${m[1]}; consult GitHub REST API docs for this code.`);\n  } else throw e;\n}","preventionTips":["Keep repomix updated so new GitHub API statuses/behaviors are handled explicitly.","Log the full status and statusText (they are in the message) before deciding on recovery.","Verify token format/validity to rule out 401s, the most common unexpected status."],"tags":["github","http","api","unexpected-status"],"backgroundTag":"http-error-status","analyzedSha":"f465ad909315a22120636baf03fa5e28701a50cb","analyzedAt":"2026-08-29T01:27:42.024Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}