{"record":{"id":"2ae5719f1dd86bb4","repo":"mastra-ai/mastra","slug":"request-failed-with-status-response-status-r","errorCode":null,"errorMessage":"request failed with status ${response.status}: ${responseText}","messagePattern":"request failed with status (.+?): (.+?)","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"integrations/brightdata/src/client.ts","lineNumber":79,"sourceCode":"        Authorization: `Bearer ${apiKey}`,\n        'Content-Type': 'application/json',\n      },\n      method: 'POST',\n      signal: controller.signal,\n    });\n\n    const responseText = await response.text();\n\n    if (!response.ok) {\n      if (response.status === 401 || response.status === 403) {\n        throw new Error('invalid API key or insufficient permissions');\n      }\n\n      if (response.status === 400) {\n        throw new Error(`bad request: ${responseText}`);\n      }\n\n      throw new Error(`request failed with status ${response.status}: ${responseText}`);\n    }\n\n    if (body.format === 'json') {\n      return responseText ? JSON.parse(responseText) : {};\n    }\n\n    return responseText;\n  } catch (error) {\n    if (error instanceof Error && error.name === 'AbortError') {\n      throw new Error(`Request timed out after ${effectiveTimeout}ms`);\n    }\n    throw error;\n  } finally {\n    clearTimeout(timeoutId);\n  }\n}\n\nfunction buildGoogleSearchUrl(query: string, options: SearchOptions = {}) {","sourceCodeStart":61,"sourceCodeEnd":97,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/integrations/brightdata/src/client.ts#L61-L97","documentation":"The generic failure branch of requestBrightData: thrown for any non-ok response that is not 401/403/400 (e.g. 404, 429, 500, 502, 503). The message includes both the HTTP status and the response body for diagnosis. It means the request reached Bright Data but the server could not or would not complete it for a reason other than auth or malformed input.","triggerScenarios":"Any requestBrightData call whose response status is outside {400, 401, 403} — Bright Data outages (5xx), rate limiting (429), wrong endpoint/zone URL (404), or gateway errors.","commonSituations":"Hitting rate limits during bursts of searches; transient Bright Data incidents; misconfigured custom zone producing a 404; proxy/unlock zone not provisioned for the account.","solutions":["Check the status code and body in the error message; treat 429 as rate limiting and 5xx as provider-side trouble.","For 429, add client-side throttling/backoff between requests.","For 404, verify the zone/endpoint configuration (BRIGHTDATA_SERP_ZONE, BRIGHTDATA_WEB_UNLOCKER_ZONE).","For persistent 5xx, check the Bright Data status page/dashboard and retry with exponential backoff.","Check https://status.brightdata.com or your dashboard for ongoing incidents."],"exampleFix":"// before\nconst result = await client.search.google(q); // throws on 429/5xx\n// after\ntry {\n  const result = await client.search.google(q);\n} catch (e) {\n  if (/status 429/.test(e.message)) await sleep(backoff);\n  else throw e;\n}","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"async function searchWithRetry(query: string, maxRetries = 3): Promise<unknown> {\n  for (let attempt = 1; attempt <= maxRetries; attempt++) {\n    try {\n      return await client.search.google(query);\n    } catch (err) {\n      const msg = err instanceof Error ? err.message : '';\n      const retryable = /status (429|5\\d\\d)/.test(msg);\n      if (!retryable || attempt === maxRetries) throw err;\n      await new Promise((r) => setTimeout(r, 2 ** attempt * 500)); // exponential backoff\n    }\n  }\n}","preventionTips":["Throttle request rate to stay under Bright Data rate limits.","Use exponential backoff for 429 and 5xx responses only; never retry 4xx input errors.","Monitor provider status pages and set alerts for elevated failure rates.","Pin and review zone configuration so endpoint/zone names stay valid."],"tags":["network","http","server-error","rate-limit"],"backgroundTag":"http-request-failed","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T08:17:16.595Z"}