oven-sh/bun · error · Error

GitHub API request failed: ${response.status} ${response.sta

Error message

GitHub API request failed: ${response.status} ${response.statusText}

What it means

Generic non-OK response from the GitHub REST call after the rate-limit branch (429/403) did not match. The message includes status and statusText only, so the response body with the actual GitHub error (message, documentation_url) is lost.

Source

Thrown at scripts/auto-close-duplicates.ts:91

  // Handle rate limit errors with retry
  if (response.status === 429 || response.status === 403) {
    if (retryCount >= maxRetries) {
      throw new Error(`GitHub API rate limit exceeded after ${maxRetries} retries`);
    }

    const retryAfter = response.headers.get("retry-after");
    const waitTime = retryAfter ? parseInt(retryAfter) * 1000 : Math.min(1000 * Math.pow(2, retryCount), 32000);

    console.warn(
      `[WARNING] Rate limited (${response.status}), retry ${retryCount + 1}/${maxRetries} after ${waitTime}ms`,
    );
    await sleep(waitTime);

    return githubRequest<T>(endpoint, token, method, body, retryCount + 1);
  }

  if (!response.ok) {
    throw new Error(`GitHub API request failed: ${response.status} ${response.statusText}`);
  }

  return response.json();
}

async function fetchAllComments(
  owner: string,
  repo: string,
  issueNumber: number,
  token: string,
): Promise<GitHubComment[]> {
  const allComments: GitHubComment[] = [];
  let page = 1;
  const perPage = 100;

  while (true) {
    const comments: GitHubComment[] = await githubRequest(
      `/repos/${owner}/${repo}/issues/${issueNumber}/comments?per_page=${perPage}&page=${page}`,

View on GitHub (pinned to 8c5296ac45)

Solutions

  1. Include the response body in the thrown error to see GitHub's own message and documentation_url
  2. Verify token validity and scopes for the endpoint being called
  3. Check owner/repo/issue numbers passed to the endpoint

Example fix

// before
if (!response.ok) {
  throw new Error(`GitHub API request failed: ${response.status} ${response.statusText}`);
}

// after
if (!response.ok) {
  const body = await response.text();
  throw new Error(`GitHub API request failed: ${response.status} ${response.statusText} ${body.slice(0, 300)}`);
}
Defensive patterns

Strategy: retry

Validate before calling

null

Prevention

When it happens

Trigger: 401 from an invalid/expired token; 404 from a wrong endpoint or missing repo; 422 validation errors on POST bodies; GitHub 5xx outside the retry path.

Common situations: Expired GITHUB_TOKEN in a long-lived context; typo'd repo/issue number; GraphQL/REST shape mismatch in a POST payload.

Related errors


AI-assisted analysis of oven-sh/bun@8c5296ac45 (2026-08-16). Data as JSON: /api/errors/5c2fca46d7165a98. Report an issue: GitHub.