Mintplex-Labs/anything-llm · error · Error
${res.status} - ${res.statusText}
Error message
${res.status} - ${res.statusText} What it means
Thrown by the Brave Search provider when fetch() to the Brave Search API returns a non-OK status. Authentication uses AGENT_BRAVE_API_KEY in the x-subscription-token header. Notably, this error message is the simplest of all search providers — it only includes status and statusText, without the truncated key or query, making it slightly harder to diagnose. The .catch logs 'Brave Search Error' and returns a failure string.
Source
Thrown at server/utils/agents/aibitat/plugins/web-browsing.js:1226
return `Search is disabled and no content was found. This functionality is disabled because the user has not set it up yet.`;
}
this.super.introspect(
`${this.caller}: Using Brave to search for "${
query.length > 100 ? `${query.slice(0, 100)}...` : query
}"`
);
const { response, error } = await fetch(searchURL.toString(), {
method: "GET",
headers: {
"Content-Type": "application/json",
"x-subscription-token": process.env.AGENT_BRAVE_API_KEY,
},
})
.then((res) => {
if (res.ok) return res.json();
throw new Error(`${res.status} - ${res.statusText}`);
})
.then((data) => {
return { response: data, error: null };
})
.catch((e) => {
this.super.handlerProps.log(`Brave Search Error: ${e.message}`);
return { response: null, error: e.message };
});
if (error)
return `There was an error searching for content. ${error}`;
const data = [];
const searchResults = response?.web?.results ?? [];
searchResults.forEach((searchResult) => {
const { url, title, description } = searchResult;
data.push({
title,
link: url,View on GitHub (pinned to 526360e320)
Solutions
- Verify AGENT_BRAVE_API_KEY is set to a valid Brave Search API subscription key from api.search.brave.com.
- A 401 means the x-subscription-token is wrong or empty — confirm the env var is set.
- A 429 means the monthly quota is exhausted — upgrade the plan or wait for reset.
- Since the error lacks the key/query context, log the full request details separately for debugging.
Example fix
// before
throw new Error(`${res.status} - ${res.statusText}`);
// improved — include diagnostic context consistent with other providers
throw new Error(
`${res.status} - ${res.statusText}. params: ${JSON.stringify({
auth: this.middleTruncate(process.env.AGENT_BRAVE_API_KEY, 5),
q: query
})}`
); Defensive patterns
Strategy: validation
Validate before calling
if (!process.env.AGENT_BRAVE_API_KEY) {
throw new Error("AGENT_BRAVE_API_KEY is not set. Configure it to use Brave Search.");
} Try / catch
try {
const results = await braveSearch(query);
return results;
} catch (e) {
// Note: Brave error only has status/statusText — no key/query context
if (e.message.startsWith("401") || e.message.startsWith("403")) {
return "Brave Search key invalid or subscription suspended. Check AGENT_BRAVE_API_KEY.";
}
if (e.message.startsWith("429")) {
return "Brave Search monthly quota exhausted (free tier: 2,000/month). Upgrade the plan.";
}
throw e;
} Prevention
- Verify AGENT_BRAVE_API_KEY is set before using Brave Search.
- Since the error lacks diagnostic context, log the full request details separately.
- Monitor the 2,000-query/month free-tier limit.
- Ensure the key is from api.search.brave.com, not another Brave product.
When it happens
Trigger: Brave returns 401 (invalid or missing x-subscription-token), 429 (rate limit — Brave's free tier allows 2,000 queries/month), 403 (subscription suspended or query not allowed), 400 (bad query parameter), or 5xx. An unset AGENT_BRAVE_API_KEY sends an empty x-subscription-token header, always triggering 401.
Common situations: AGENT_BRAVE_API_KEY not configured; free monthly quota exhausted; key from a canceled subscription; using a Brave Search API key intended for a different Brave product; Brave API temporarily down.
Related errors
- ${res.status} - ${res.statusText}. params: ${JSON.stringify(
- ${res.status} - ${res.statusText}. params: ${JSON.stringify(
- ${res.status} - ${res.statusText}. params: ${JSON.stringify(
- ${res.status} - ${res.statusText}. params: ${JSON.stringify(
- ${res.status} - ${res.statusText}. params: ${JSON.stringify(
AI-assisted analysis of Mintplex-Labs/anything-llm@526360e320 (2026-08-13).
Data as JSON: /api/errors/c7e9c704901d9372.
Report an issue: GitHub.