stablyai/orca · error

Translation request failed with status ${response.status}

Error message

Translation request failed with status ${response.status}

What it means

Thrown by translateText in bootstrap-locale-catalog.mjs when the Google Translate gtx endpoint returns a non-OK HTTP status. The function retries up to 5 times with linear backoff (500, 1000, 1500, 2000, 2500 ms) before rethrowing the last error; this error specifically signals an HTTP-level failure (4xx/5xx) rather than a network exception.

Source

Thrown at config/scripts/bootstrap-locale-catalog.mjs:78

function shouldSkipTranslation(text) {
  return shouldPreserveEnglishValue(text)
}

async function translateText(text, targetLanguage) {
  const url = new URL('https://translate.googleapis.com/translate_a/single')
  url.searchParams.set('client', 'gtx')
  url.searchParams.set('sl', 'en')
  url.searchParams.set('tl', targetLanguage)
  url.searchParams.set('dt', 't')
  url.searchParams.set('q', text)

  let lastError
  for (let attempt = 0; attempt < 5; attempt += 1) {
    try {
      const response = await fetch(url)
      if (!response.ok) {
        throw new Error(`Translation request failed with status ${response.status}`)
      }
      const payload = await response.json()
      return payload[0].map((part) => part[0]).join('')
    } catch (error) {
      lastError = error
      await new Promise((resolve) => setTimeout(resolve, 500 * (attempt + 1)))
    }
  }
  throw lastError
}

async function mapWithConcurrency(items, concurrency, mapper) {
  const results = Array.from({ length: items.length })
  let nextIndex = 0

  async function worker() {
    while (nextIndex < items.length) {
      const currentIndex = nextIndex

View on GitHub (pinned to 1136503c6a)

Solutions

  1. Wait and retry — the gtx quota resets over time; the script's built-in 5 retries with linear backoff handle transient 429s but a sustained block needs a longer pause.
  2. Reduce the workload: the script caches translated values in .<locale>-catalog-cache.json, so keep that cache and only translate new strings.
  3. Lower concurrency from 2 to 1 (mapWithConcurrency third arg) and/or increase the 200ms throttle between requests to stay under the rate limit.
  4. For very long strings, split them before translation to avoid HTTP 414 URI-Too-Long.
  5. If the block is permanent for your IP, run from a different network or pre-translate offline and populate the cache file manually.

Example fix

// before — full catalog, concurrency 2, no throttle headroom
// await mapWithConcurrency(toTranslate, 2, async (value) => { ... await new Promise(r => setTimeout(r, 200)) })

// after — concurrency 1, longer throttle, reuse cache
// await mapWithConcurrency(toTranslate, 1, async (value) => { ... await new Promise(r => setTimeout(r, 800)) })
Defensive patterns

Strategy: retry

Validate before calling

async function translateWithBudget(text, targetLanguage, maxAttempts = 5) {
  // Pre-split very long strings to avoid HTTP 414.
  const MAX_QUERY = 1500
  if (text.length > MAX_QUERY) {
    throw new Error(`Refusing to translate: text length ${text.length} exceeds ${MAX_QUERY} (would 414).`)
  }
  return translateText(text, targetLanguage, maxAttempts)
}

Try / catch

try {
  await translateText(value, lang)
} catch (error) {
  if (/Translation request failed with status 429|403|503/.test(error.message)) {
    console.error(`Translation blocked (${error.message}). Keeping cached value; rerun later.`)
    return cache.get(value) ?? value
  }
  throw error
}

Prevention

When it happens

Trigger: Rate limiting (HTTP 429) from the free gtx endpoint; IP-based blocking (403/429) after many requests in a short window; the endpoint returning 502/503 during a Google outage; sending a payload that exceeds the query-string length limit (414).

Common situations: Re-running the locale bootstrap on a fresh machine many times in a day; large catalog with many unique strings hitting the per-IP quota; corporate egress IP shared across CI runners triggering the same rate limit; a single very long string blowing past the URL length cap.

Related errors


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