{"record":{"id":"411b4fe9bf61245c","repo":"Mintplex-Labs/anything-llm","slug":"res-status-res-statustext-params-json-411b4f","errorCode":null,"errorMessage":"${res.status} - ${res.statusText}. params: ${JSON.stringify({ auth: this.middleTruncate(process.env.AGENT_TAVILY_API_KEY, 5), q: query })}","messagePattern":"(.+?) - (.+?)\\. params: (.+?)\\)\\}","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"server/utils/agents/aibitat/plugins/web-browsing.js","lineNumber":911,"sourceCode":"              `${this.caller}: Using Tavily to search for \"${\n                query.length > 100 ? `${query.slice(0, 100)}...` : query\n              }\"`\n            );\n\n            const url = \"https://api.tavily.com/search\";\n            const { response, error } = await fetch(url, {\n              method: \"POST\",\n              headers: {\n                \"Content-Type\": \"application/json\",\n              },\n              body: JSON.stringify({\n                api_key: process.env.AGENT_TAVILY_API_KEY,\n                query: query,\n              }),\n            })\n              .then((res) => {\n                if (res.ok) return res.json();\n                throw new Error(\n                  `${res.status} - ${res.statusText}. params: ${JSON.stringify({ auth: this.middleTruncate(process.env.AGENT_TAVILY_API_KEY, 5), q: query })}`\n                );\n              })\n              .then((data) => {\n                return { response: data, error: null };\n              })\n              .catch((e) => {\n                this.super.handlerProps.log(\n                  `Tavily Search Error: ${e.message}`\n                );\n                return { response: null, error: e.message };\n              });\n\n            if (error)\n              return `There was an error searching for content. ${error}`;\n\n            const data = [];\n            response.results?.forEach((searchResult) => {","sourceCodeStart":893,"sourceCodeEnd":929,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/526360e320da9d1b36074be5ed64fe76e5bbfbbd/server/utils/agents/aibitat/plugins/web-browsing.js#L893-L929","documentation":"Thrown by the Tavily search provider when a POST to the Tavily API returns a non-OK status. Authentication is via the api_key field in the JSON body (not a header). The error captures status, statusText, a truncated AGENT_TAVILY_API_KEY, and the query. The .catch logs 'Tavily Search Error' and returns a failure string.","triggerScenarios":"Tavily returns 401 (invalid or missing api_key in the body), 429 (rate limit — Tavily has strict per-plan limits), 400 (malformed query), or 5xx. Because the key travels in the body, an unset AGENT_TAVILY_API_KEY sends api_key: undefined which Tavily rejects.","commonSituations":"AGENT_TAVILY_API_KEY not set; free tier (1,000 searches/month) exhausted; key from a canceled account; rapid agent queries hitting the rate limit; Tavily API version change requiring a different body format.","solutions":["Confirm AGENT_TAVILY_API_KEY is set to a valid key from app.tavily.com.","A 429 means the monthly plan limit is reached — upgrade the plan or wait for the cycle reset.","A 401 means the key is wrong — check the truncated value; 'undef...' indicates the env var is unset.","For 400 errors, verify the query is a non-empty string."],"exampleFix":"// before\nbody: JSON.stringify({ api_key: process.env.AGENT_TAVILY_API_KEY, query: query }),\n// throw on non-OK\n\n// caller-side fix\nif (!process.env.AGENT_TAVILY_API_KEY) {\n  return \"AGENT_TAVILY_API_KEY is not configured.\";\n}","handlingStrategy":"validation","validationCode":"if (!process.env.AGENT_TAVILY_API_KEY) {\n  throw new Error(\"AGENT_TAVILY_API_KEY is not set. Configure it to use Tavily search.\");\n}","typeGuard":null,"tryCatchPattern":"try {\n  const results = await tavilySearch(query);\n  return results;\n} catch (e) {\n  if (e.message.startsWith(\"429\")) {\n    // Tavily monthly limit — cannot retry, must wait for reset\n    return \"Tavily monthly search limit reached. Upgrade the plan or wait for reset.\";\n  }\n  if (e.message.startsWith(\"401\")) {\n    return \"Tavily API key invalid. Check AGENT_TAVILY_API_KEY.\";\n  }\n  throw e;\n}","preventionTips":["Verify AGENT_TAVILY_API_KEY is set before using Tavily search.","Monitor monthly search quota (free tier is 1,000/month).","Remember the key is in the request body, not a header — ensure it serializes correctly.","Handle 429 as a hard monthly limit, not a transient retry scenario."],"tags":["tavily","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"}