diegosouzapw/OmniRoute · error · Error

GitHub API error

Error message

GitHub API error: ${error}

What it means

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.

Solutions

  1. Refresh the Copilot token and retry for 401 responses
  2. Back off for 429 rate limits
  3. Check GitHub status for copilot_internal API incidents
Defensive patterns

Strategy: retry

When it happens

Trigger: Thrown at src/lib/usage/fetcher.ts:78 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of diegosouzapw/OmniRoute@a179ffed5b (2026-08-25). Data as JSON: /api/errors/67e5af5f6d125e70. Report an issue: GitHub.

Appendix: source

Thrown at src/lib/usage/fetcher.ts:78

/**
 * GitHub Copilot Usage
 */
async function getGitHubUsage(accessToken, providerSpecificData) {
  try {
    // Use copilotToken for copilot_internal API, not GitHub OAuth accessToken
    const copilotToken = providerSpecificData?.copilotToken;
    if (!copilotToken) {
      throw new Error("Copilot token not found. Please refresh token first.");
    }

    const response = await fetch("https://api.github.com/copilot_internal/user", {
      headers: getGitHubCopilotInternalUserHeaders(`Bearer ${copilotToken}`),
    });

    if (!response.ok) {
      const error = await response.text();
      throw new Error(`GitHub API error: ${error}`);
    }

    const data = await response.json();

    // Handle different response formats (paid vs free)
    if (data.quota_snapshots) {
      // Paid plan format
      const snapshots = data.quota_snapshots;
      return {
        plan: data.copilot_plan,
        resetDate: data.quota_reset_date,
        quotas: {
          chat: formatGitHubQuotaSnapshot(snapshots.chat),
          completions: formatGitHubQuotaSnapshot(snapshots.completions),
          premium_interactions: formatGitHubQuotaSnapshot(snapshots.premium_interactions),
        },
      };
    } else if (data.monthly_quotas || data.limited_user_quotas) {

View on GitHub (pinned to a179ffed5b)