{"record":{"id":"67e5af5f6d125e70","repo":"diegosouzapw/OmniRoute","slug":"github-api-error-error","errorCode":null,"errorMessage":"GitHub API error: ${error}","messagePattern":"GitHub API error: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/lib/usage/fetcher.ts","lineNumber":78,"sourceCode":"\n/**\n * GitHub Copilot Usage\n */\nasync function getGitHubUsage(accessToken, providerSpecificData) {\n  try {\n    // Use copilotToken for copilot_internal API, not GitHub OAuth accessToken\n    const copilotToken = providerSpecificData?.copilotToken;\n    if (!copilotToken) {\n      throw new Error(\"Copilot token not found. Please refresh token first.\");\n    }\n\n    const response = await fetch(\"https://api.github.com/copilot_internal/user\", {\n      headers: getGitHubCopilotInternalUserHeaders(`Bearer ${copilotToken}`),\n    });\n\n    if (!response.ok) {\n      const error = await response.text();\n      throw new Error(`GitHub API error: ${error}`);\n    }\n\n    const data = await response.json();\n\n    // Handle different response formats (paid vs free)\n    if (data.quota_snapshots) {\n      // Paid plan format\n      const snapshots = data.quota_snapshots;\n      return {\n        plan: data.copilot_plan,\n        resetDate: data.quota_reset_date,\n        quotas: {\n          chat: formatGitHubQuotaSnapshot(snapshots.chat),\n          completions: formatGitHubQuotaSnapshot(snapshots.completions),\n          premium_interactions: formatGitHubQuotaSnapshot(snapshots.premium_interactions),\n        },\n      };\n    } else if (data.monthly_quotas || data.limited_user_quotas) {","sourceCodeStart":60,"sourceCodeEnd":96,"githubUrl":"https://github.com/diegosouzapw/OmniRoute/blob/a179ffed5bb2e0b883b9ae7214ce8717b2a94c4d/src/lib/usage/fetcher.ts#L60-L96","documentation":"Upstream failure in getGitHubUsage: the copilot_internal/user request returned non-ok and the raw response text is embedded as `error` before rethrowing. Typically an expired copilotToken (401), rate limit (429), or GitHub-side incident — the request itself was well-formed with the cached token.","triggerScenarios":"Thrown at src/lib/usage/fetcher.ts:78 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Refresh the Copilot token and retry for 401 responses","Back off for 429 rate limits","Check GitHub status for copilot_internal API incidents"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"a179ffed5bb2e0b883b9ae7214ce8717b2a94c4d","analyzedAt":"2026-08-25T18:35:09.898Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}