mastra-ai/mastra · error
request failed with status ${response.status}: ${responseTex
Error message
request failed with status ${response.status}: ${responseText} What it means
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.
Source
Thrown at integrations/brightdata/src/client.ts:79
Authorization: `Bearer ${apiKey}`,
'Content-Type': 'application/json',
},
method: 'POST',
signal: controller.signal,
});
const responseText = await response.text();
if (!response.ok) {
if (response.status === 401 || response.status === 403) {
throw new Error('invalid API key or insufficient permissions');
}
if (response.status === 400) {
throw new Error(`bad request: ${responseText}`);
}
throw new Error(`request failed with status ${response.status}: ${responseText}`);
}
if (body.format === 'json') {
return responseText ? JSON.parse(responseText) : {};
}
return responseText;
} catch (error) {
if (error instanceof Error && error.name === 'AbortError') {
throw new Error(`Request timed out after ${effectiveTimeout}ms`);
}
throw error;
} finally {
clearTimeout(timeoutId);
}
}
function buildGoogleSearchUrl(query: string, options: SearchOptions = {}) {View on GitHub (pinned to 75dd419e61)
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.
Example fix
// before
const result = await client.search.google(q); // throws on 429/5xx
// after
try {
const result = await client.search.google(q);
} catch (e) {
if (/status 429/.test(e.message)) await sleep(backoff);
else throw e;
} Defensive patterns
Strategy: retry
Try / catch
async function searchWithRetry(query: string, maxRetries = 3): Promise<unknown> {
for (let attempt = 1; attempt <= maxRetries; attempt++) {
try {
return await client.search.google(query);
} catch (err) {
const msg = err instanceof Error ? err.message : '';
const retryable = /status (429|5\d\d)/.test(msg);
if (!retryable || attempt === maxRetries) throw err;
await new Promise((r) => setTimeout(r, 2 ** attempt * 500)); // exponential backoff
}
}
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: 'Something went wrong' / 'Request failed (500)' / 'HTTP error! status: 404' — what failed HTTP requests actually mean and how to find the real cause — this error's family across 28 libraries.
Related errors
- Auth check failed (${res.status})
- Slack OAuth HTTP error: ${tokenResponse.status} ${tokenRespo
- Telegram ${method} failed: ${detail}
- Failed to stream background tasks: ${response.statusText}
- Failed to stream agent builder action: ${response.statusText
AI-assisted analysis of mastra-ai/mastra@75dd419e61 (2026-08-30).
Data as JSON: /api/errors/2ae5719f1dd86bb4.
Report an issue: GitHub.