{"record":{"id":"c36b5bf3af6a85d8","repo":"Mintplex-Labs/anything-llm","slug":"res-status-res-statustext-params-json-c36b5b","errorCode":null,"errorMessage":"${res.status} - ${res.statusText}. params: ${JSON.stringify({ auth: this.middleTruncate(process.env.AGENT_SERPER_DEV_KEY, 5), q: query })}","messagePattern":"(.+?) - (.+?)\\. params: (.+?)\\)\\}","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/utils/agents/aibitat/plugins/web-browsing.js","lineNumber":533,"sourceCode":"              `${this.caller}: Using Serper.dev to search for \"${\n                query.length > 100 ? `${query.slice(0, 100)}...` : query\n              }\"`\n            );\n            const { response, error } = await fetch(\n              \"https://google.serper.dev/search\",\n              {\n                method: \"POST\",\n                headers: {\n                  \"X-API-KEY\": process.env.AGENT_SERPER_DEV_KEY,\n                  \"Content-Type\": \"application/json\",\n                },\n                body: JSON.stringify({ q: query }),\n                redirect: \"follow\",\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_SERPER_DEV_KEY, 5), q: query })}`\n                );\n              })\n              .then((data) => {\n                return { response: data, error: null };\n              })\n              .catch((e) => {\n                this.super.handlerProps.log(`Serper.dev 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            if (response.hasOwnProperty(\"knowledgeGraph\"))\n              data.push(response.knowledgeGraph);\n            response.organic?.forEach((searchResult) => {\n              const { title, link, snippet } = searchResult;","sourceCodeStart":515,"sourceCodeEnd":551,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/a145d4d87d086bdb31d50f9bf9cd9c46d311780c/server/utils/agents/aibitat/plugins/web-browsing.js#L515-L551","documentation":"Thrown inside the Serper.dev branch of the web-browsing plugin when the POST to google.serper.dev/search returns non-ok. The request sends X-API-KEY: AGENT_SERPER_DEV_KEY with a JSON body {q: query}; the error embeds status, statusText, query, and the key middle-truncated to 5 chars. The wrapping .catch logs 'Serper.dev Error' and returns the message to the agent as an error string rather than rethrowing.","triggerScenarios":"AGENT_SERPER_DEV_KEY missing/invalid (401/403); free-tier 2500-credit quota exhausted or rate limited (429); malformed query payload (400); serper.dev outage (5xx).","commonSituations":"Key created but never funded after trial; server process predates the .env change adding the key; using a SerpApi key in AGENT_SERPER_DEV_KEY.","solutions":["Confirm AGENT_SERPER_DEV_KEY is a valid serper.dev key and restart the server after .env changes.","Check remaining credits/rate limits on the Serper dashboard for 429s; upgrade or wait out the window.","For persistent 4xx, curl the endpoint directly with the X-API-KEY header to see Serper's own error body."],"exampleFix":"# before\ncurl-equivalent fails: 403 - Forbidden (key from another provider)\nAGENT_SERPER_DEV_KEY=serpapi-key-oops\n\n# after\nAGENT_SERPER_DEV_KEY=<real serper.dev key>\n# restart server","handlingStrategy":"validation","validationCode":"const KEY = process.env.AGENT_SERPER_DEV_KEY;\nif (!KEY || KEY.length < 20) {\n  throw new Error(\"AGENT_SERPER_DEV_KEY missing or malformed — set a valid serper.dev key and restart\");\n}","typeGuard":null,"tryCatchPattern":"const out = await webSearch(query);\nif (typeof out === \"string\" && out.includes(\"Serper.dev Error\")) {\n  if (/40[13]/.test(out)) fixSerperKey();\n  else if (out.includes(\"429\")) backoffThenRetry(query); // credits/QPS\n  else checkRequestBody(out);\n}","preventionTips":["Fund the serper.dev plan and monitor remaining credits (free tier is 2500 searches).","Keep provider env vars mutually exclusive to avoid cross-key mistakes.","Restart the server after updating keys."],"tags":["web-search","serper-dev","http-error","api-key","agent-tools"],"backgroundTag":"search-api-http-error","analyzedSha":"a145d4d87d086bdb31d50f9bf9cd9c46d311780c","analyzedAt":"2026-08-18T10:02:21.017Z","contentChangedAt":"2026-08-18T10:02:21.017Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}