{"record":{"id":"718b1862ae680b42","repo":"davila7/claude-code-templates","slug":"github-api-error-response-status","errorCode":null,"errorMessage":"GitHub API error: ${response.status}","messagePattern":"GitHub API error: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"cli-tool/src/index.js","lineNumber":1475,"sourceCode":"          // Return comprehensive fallback list\n          return [\n            { name: 'frontend-developer', path: 'development-team/frontend-developer', category: 'development-team' },\n            { name: 'backend-developer', path: 'development-team/backend-developer', category: 'development-team' },\n            { name: 'fullstack-developer', path: 'development-team/fullstack-developer', category: 'development-team' },\n            { name: 'devops-engineer', path: 'development-team/devops-engineer', category: 'development-team' },\n            { name: 'nextjs-architecture-expert', path: 'web-tools/nextjs-architecture-expert', category: 'web-tools' },\n            { name: 'react-developer', path: 'web-tools/react-developer', category: 'web-tools' },\n            { name: 'vue-developer', path: 'web-tools/vue-developer', category: 'web-tools' },\n            { name: 'data-scientist', path: 'data-analytics/data-scientist', category: 'data-analytics' },\n            { name: 'data-analyst', path: 'data-analytics/data-analyst', category: 'data-analytics' },\n            { name: 'security-auditor', path: 'security/security-auditor', category: 'security' },\n            { name: 'api-security-audit', path: 'api-security-audit', category: 'root' },\n            { name: 'database-optimization', path: 'database-optimization', category: 'root' },\n            { name: 'react-performance-optimization', path: 'react-performance-optimization', category: 'root' }\n          ];\n        }\n      }\n      throw new Error(`GitHub API error: ${response.status}`);\n    }\n    \n    const contents = await response.json();\n    const agents = [];\n    \n    for (const item of contents) {\n      if (item.type === 'file' && item.name.endsWith('.md')) {\n        // Direct agent file\n        agents.push({\n          name: item.name.replace('.md', ''),\n          path: item.name.replace('.md', ''),\n          category: 'root'\n        });\n      } else if (item.type === 'dir') {\n        // Category directory, fetch its contents\n        try {\n          const categoryResponse = await fetch(`https://api.github.com/repos/davila7/claude-code-templates/contents/cli-tool/components/agents/${item.name}`);\n          if (categoryResponse.ok) {","sourceCodeStart":1457,"sourceCodeEnd":1493,"githubUrl":"https://github.com/davila7/claude-code-templates/blob/a0851ed10c7c60463dac8cfaaca124cf32d5804d/cli-tool/src/index.js#L1457-L1493","documentation":"Thrown after listing agent directories/components via the GitHub Contents API when the response is not OK (and none of the built-in fallback category listings applied). This is the batch/interactive agent listing path: a failed GitHub API call (rate limit 403, 5xx, network failure) aborts listing available agents.","triggerScenarios":"Fetching the component agents directory listing (github repo contents API) during interactive mode or `--agent list`-style flows; any non-200 response (403 rate limit, 500, proxy block) that doesn't match the hardcoded fallback branches throws.","commonSituations":"Unauthenticated GitHub API rate limit (60 req/hr/IP) exhausted after repeated CLI runs; CI runners on shared IPs; GitHub API incidents; restrictive corporate firewalls.","solutions":["Wait for rate-limit reset or export GITHUB_TOKEN to authenticate API requests","Retry after checking https://www.githubstatus.com","Run from a network that doesn't block api.github.com","Pin an exact agent name (`--agent <name>`) to skip the directory listing entirely"],"exampleFix":"// before\nthrow new Error(`GitHub API error: ${response.status}`);\n// after\nconsole.error(`GitHub API error: ${response.status}. Rate limited? Set GITHUB_TOKEN.`);\nreturn []; // graceful degradation to empty list","handlingStrategy":"fallback","validationCode":"const r = await fetch('https://api.github.com/rate_limit');\nconst { resources: { core: { remaining } } } = await r.json();\nif (remaining < 10 && !process.env.GITHUB_TOKEN) {\n  console.warn('GitHub API quota low — listing may fail; set GITHUB_TOKEN');\n}","typeGuard":null,"tryCatchPattern":"try {\n  const agents = await listAvailableAgents();\n  renderMenu(agents);\n} catch (e) {\n  if (/GitHub API error: 403/.test(e.message)) {\n    renderMenu(FALLBACK_AGENT_LIST); // use a pinned local list\n  } else throw e;\n}","preventionTips":["Cache the agent list locally between runs instead of re-fetching","Set GITHUB_TOKEN for authenticated requests","Pin specific agents with --agent <name> to bypass listing"],"tags":["github-api","http-error","rate-limit","agent-listing","network"],"backgroundTag":"github-api-rate-limited","analyzedSha":"a0851ed10c7c60463dac8cfaaca124cf32d5804d","analyzedAt":"2026-08-28T14:11:56.058Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}