stablyai/orca · error

Gitea request failed: HTTP ${response.status}

Error message

Gitea request failed: HTTP ${response.status}

What it means

Thrown by requestJsonAtBase in the Gitea client when the HTTP response is not ok AND the caller passed throwOnFailure=true. The throwOnFailure flag exists specifically for the existing-review lookup behind PR Create, which must distinguish a genuine transport/auth failure (this throw) from an accepted 'no PR exists' (the null return path). The status code is included verbatim so the caller can classify 401/403/404/5xx.

Source

Thrown at src/main/gitea/client.ts:101

  options: RequestOptions = {},
  // Why: the existing-review lookup behind Create must distinguish a real
  // transport/auth failure from an accepted "no PR". When true, a failed request
  // throws instead of collapsing to null so callers never report false not_found.
  throwOnFailure = false
): Promise<T | null> {
  const config = getAuthConfig()
  try {
    const response = await fetch(apiUrl(baseUrl, path, options.searchParams), {
      headers: {
        Accept: 'application/json',
        ...authHeaders(config)
      },
      signal: AbortSignal.timeout(options.timeoutMs ?? REQUEST_TIMEOUT_MS)
    })
    if (!response.ok) {
      await cancelUnreadResponseBody(response)
      if (throwOnFailure) {
        throw new Error(`Gitea request failed: HTTP ${response.status}`)
      }
      return null
    }
    return (await response.json()) as T
  } catch (error) {
    if (throwOnFailure) {
      throw error
    }
    return null
  }
}

function requestJson<T>(
  repo: GiteaRepoRef,
  path: string,
  options: RequestOptions = {},
  throwOnFailure = false
): Promise<T | null> {

View on GitHub (pinned to 1136503c6a)

Solutions

  1. Check the HTTP status: 401/403 → fix ORCA_GITEA_TOKEN; 404 → fix ORCA_GITEA_API_BASE_URL (ensure it normalizes to include /api/v1); 5xx → check the Gitea instance.
  2. Verify the token with `curl -H "Authorization: token $ORCA_GITEA_TOKEN" $ORCA_GITEA_API_BASE_URL/user`.
  3. Confirm the base URL does not already include a trailing /api/v1 twice (normalizeGiteaApiBaseUrl appends one only if absent).
  4. If 429, back off — the client uses a 5s default and 15s for PR list pages.
Defensive patterns

Strategy: try-catch

Validate before calling

function giteaConfigLooksValid(): boolean {
  const base = (process.env.ORCA_GITEA_API_BASE_URL ?? '').trim()
  const token = (process.env.ORCA_GITEA_TOKEN ?? '').trim()
  return base.length > 0 && token.length > 0
}

Try / catch

try {
  const review = await requestJsonAtBase(baseUrl, path, opts, /*throwOnFailure*/ true)
} catch (err) {
  const status = /HTTP (\d{3})/.exec((err as Error).message)?.[1]
  if (status === '401' || status === '403') promptReconfigureToken()
  else if (status === '404') promptReconfigureBaseUrl()
  else toast.error(`Gitea request failed (${status})`)
}

Prevention

When it happens

Trigger: Gitea/Forgejo token is missing, expired, or lacks scope (401/403); the API base URL is misconfigured (404); the self-hosted instance is erroring (500/502/503); network proxy returning a non-2xx intercept page.

Common situations: ORCA_GITEA_TOKEN env var unset or revoked; ORCA_GITEA_API_BASE_URL pointing at the wrong path (missing /api/v1); token scopes narrowed after a Forgejo upgrade; reverse proxy rate-limiting returning 429.

Related errors


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