{"record":{"id":"c7e9c704901d9372","repo":"Mintplex-Labs/anything-llm","slug":"res-status-res-statustext","errorCode":null,"errorMessage":"${res.status} - ${res.statusText}","messagePattern":"\\$\\{res\\.status\\} - \\$\\{res\\.statusText\\}","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"server/utils/agents/aibitat/plugins/web-browsing.js","lineNumber":1226,"sourceCode":"              return `Search is disabled and no content was found. This functionality is disabled because the user has not set it up yet.`;\n            }\n\n            this.super.introspect(\n              `${this.caller}: Using Brave to search for \"${\n                query.length > 100 ? `${query.slice(0, 100)}...` : query\n              }\"`\n            );\n\n            const { response, error } = await fetch(searchURL.toString(), {\n              method: \"GET\",\n              headers: {\n                \"Content-Type\": \"application/json\",\n                \"x-subscription-token\": process.env.AGENT_BRAVE_API_KEY,\n              },\n            })\n              .then((res) => {\n                if (res.ok) return res.json();\n                throw new Error(`${res.status} - ${res.statusText}`);\n              })\n              .then((data) => {\n                return { response: data, error: null };\n              })\n              .catch((e) => {\n                this.super.handlerProps.log(`Brave Search Error: ${e.message}`);\n                return { response: null, error: e.message };\n              });\n            if (error)\n              return `There was an error searching for content. ${error}`;\n\n            const data = [];\n            const searchResults = response?.web?.results ?? [];\n            searchResults.forEach((searchResult) => {\n              const { url, title, description } = searchResult;\n              data.push({\n                title,\n                link: url,","sourceCodeStart":1208,"sourceCodeEnd":1244,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/526360e320da9d1b36074be5ed64fe76e5bbfbbd/server/utils/agents/aibitat/plugins/web-browsing.js#L1208-L1244","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\nthrow new Error(`${res.status} - ${res.statusText}`);\n\n// improved — include diagnostic context consistent with other providers\nthrow new Error(\n  `${res.status} - ${res.statusText}. params: ${JSON.stringify({\n    auth: this.middleTruncate(process.env.AGENT_BRAVE_API_KEY, 5),\n    q: query\n  })}`\n);","handlingStrategy":"validation","validationCode":"if (!process.env.AGENT_BRAVE_API_KEY) {\n  throw new Error(\"AGENT_BRAVE_API_KEY is not set. Configure it to use Brave Search.\");\n}","typeGuard":null,"tryCatchPattern":"try {\n  const results = await braveSearch(query);\n  return results;\n} catch (e) {\n  // Note: Brave error only has status/statusText — no key/query context\n  if (e.message.startsWith(\"401\") || e.message.startsWith(\"403\")) {\n    return \"Brave Search key invalid or subscription suspended. Check AGENT_BRAVE_API_KEY.\";\n  }\n  if (e.message.startsWith(\"429\")) {\n    return \"Brave Search monthly quota exhausted (free tier: 2,000/month). Upgrade the plan.\";\n  }\n  throw e;\n}","preventionTips":["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."],"tags":["brave-search","web-search","http","api-key","rate-limit","agent-tool"],"backgroundTag":null,"analyzedSha":"526360e320da9d1b36074be5ed64fe76e5bbfbbd","analyzedAt":"2026-08-13T01:45:47.170Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}