stablyai/orca · error · Error

GitHub request failed ${res.status} ${res.statusText}: ${bod

Error message

GitHub request failed ${res.status} ${res.statusText}: ${body.slice(0, 300)}

What it means

Thrown by the githubJson helper in config/scripts/publish-complete-draft-releases.mjs after a fetch to the GitHub REST API returns a non-2xx status (`!res.ok`). The message embeds the HTTP status code, status text, and the first 300 characters of the response body so the failure is diagnosable from the error alone. It surfaces every GitHub API failure the script makes — listing releases, verifying assets, and PATCHing a draft to published.

Source

Thrown at config/scripts/publish-complete-draft-releases.mjs:59

    return gitOutput(['rev-parse', `${tagCommit}^`], cwd) === currentCommit
  } catch {
    return false
  }
}

async function githubJson(fetchImpl, url, token, options = {}) {
  const res = await fetchImpl(url, {
    ...options,
    headers: {
      Accept: 'application/vnd.github+json',
      Authorization: `Bearer ${token}`,
      'X-GitHub-Api-Version': API_VERSION,
      ...options.headers
    }
  })
  if (!res.ok) {
    const body = await res.text().catch(() => '')
    throw new Error(`GitHub request failed ${res.status} ${res.statusText}: ${body.slice(0, 300)}`)
  }
  return res.json()
}

async function fetchReleases(repo, token, fetchImpl) {
  const releases = await githubJson(
    fetchImpl,
    `https://api.github.com/repos/${repo}/releases?per_page=100`,
    token
  )
  if (!Array.isArray(releases)) {
    throw new Error(`GitHub releases response for ${repo} was not an array`)
  }
  return releases
}

export async function publishCompleteDraftReleases({
  repo,

View on GitHub (pinned to 1136503c6a)

Solutions

  1. Inspect the embedded status: 401/403 → fix GH_TOKEN/GITHUB_TOKEN and its scopes; 404 → verify GITHUB_REPOSITORY slug; 5xx → wait and retry.
  2. For 403 secondary-rate-limit or 5xx, retry with exponential backoff (these are transient).
  3. Ensure the token has `contents:write` and `repo` scope for private repos before the run.

Example fix

// before
const releases = await githubJson(fetchImpl, url, token)

// after
async function githubJsonRetry(fetchImpl, url, token, options, retries = 3) {
  for (let attempt = 0; ; attempt++) {
    try {
      return await githubJson(fetchImpl, url, token, options)
    } catch (err) {
      const m = /GitHub request failed (\d+)/.exec(err.message)
      const status = m ? Number(m[1]) : 0
      const transient = status === 403 || status >= 500
      if (attempt < retries && transient) {
        await new Promise((r) => setTimeout(r, 2 ** attempt * 1000))
        continue
      }
      throw err
    }
  }
}
Defensive patterns

Strategy: try-catch

Validate before calling

// Before calling publishCompleteDraftReleases, sanity-check inputs
if (!token) throw new Error('GH_TOKEN/GITHUB_TOKEN not set')
if (!/^[-.\w]+\/.+$/.test(repo)) throw new Error(`Invalid repo slug: ${repo}`)

Try / catch

try {
  await publishCompleteDraftReleases({ repo, token })
} catch (err) {
  const m = /GitHub request failed (\d+)/.exec(err.message)
  const status = m ? Number(m[1]) : 0
  if ((status === 403 || status >= 500) && attempt < maxRetries) {
    await backoff(attempt)
    continue
  }
  throw err
}

Prevention

When it happens

Trigger: Call publishCompleteDraftReleases (or fetchReleases / the PATCH at line 119) when the GitHub API responds with: 401 (missing/invalid token), 403 (rate limit or insufficient token scope), 404 (wrong repo slug in GITHUB_REPOSITORY), 422 (malformed PATCH body), or any 5xx during a GitHub incident. The body slice distinguishes a rate-limit message from a scope error.

Common situations: CI runs without GH_TOKEN/GITHUB_TOKEN set correctly, a fine-grained PAT missing `contents:write`, hitting the secondary rate limit during a burst of release cuts, or a typo'd GITHUB_REPOSITORY value. GitHub 5xx outages during release windows also produce this.

Related errors


AI-assisted analysis of stablyai/orca@1136503c6a (2026-08-12). Data as JSON: /api/errors/0ee5f3e5bad5d13a. Report an issue: GitHub.