{"record":{"id":"25101e7f795183ab","repo":"Mintplex-Labs/anything-llm","slug":"res-status-res-statustext-params-json-25101e","errorCode":null,"errorMessage":"${res.status} - ${res.statusText}. params: ${JSON.stringify({ auth: this.middleTruncate(process.env.AGENT_SERPLY_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":772,"sourceCode":"              q: query,\n              language: language,\n              hl,\n              gl: proxy_location.toUpperCase(),\n            });\n            const url = `https://api.serply.io/v1/search/${params.toString()}`;\n            const { response, error } = await fetch(url, {\n              method: \"GET\",\n              headers: {\n                \"X-API-KEY\": process.env.AGENT_SERPLY_API_KEY,\n                \"Content-Type\": \"application/json\",\n                \"User-Agent\": \"anything-llm\",\n                \"X-Proxy-Location\": proxy_location,\n                \"X-User-Agent\": device_type,\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_SERPLY_API_KEY, 5), q: query })}`\n                );\n              })\n              .then((data) => {\n                if (data?.message === \"Unauthorized\")\n                  throw new Error(\n                    \"Unauthorized. Please double check your AGENT_SERPLY_API_KEY\"\n                  );\n                return { response: data, error: null };\n              })\n              .catch((e) => {\n                this.super.handlerProps.log(`Serply Error: ${e.message}`);\n                return { response: null, error: e.message };\n              });\n\n            if (error)\n              return `There was an error searching for content. ${error}`;\n","sourceCodeStart":754,"sourceCodeEnd":790,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/526360e320da9d1b36074be5ed64fe76e5bbfbbd/server/utils/agents/aibitat/plugins/web-browsing.js#L754-L790","documentation":"Thrown by the Serly search provider when fetch() returns a non-OK HTTP status. Authentication uses AGENT_SERPLY_API_KEY in the X-API-KEY header, plus optional X-Proxy-Location and X-User-Agent headers. The error captures status, statusText, a truncated key, and the query. The .catch logs 'Serly Error' and returns a failure string.","triggerScenarios":"Serly API returns 401 (invalid X-API-KEY), 402/403 (plan limit or payment required), 429 (rate limited), 400 (bad query or proxy parameter), or 5xx. Note: Serly can also return 200 OK with {message:'Unauthorized'} which is handled by a separate check (error 413). An unset key sends an empty X-API-KEY header.","commonSituations":"AGENT_SERLY_API_KEY not set or expired; free tier quota used up; invalid proxy_location parameter; rapid concurrent requests hitting the per-second limit; Serly API undergoing maintenance.","solutions":["Verify AGENT_SERLY_API_KEY is set to a valid active key from the Serly dashboard.","Check the truncated key in the error — 'undef...' means the env var is missing.","A 402/403/429 indicates plan limits — upgrade the plan or space out requests.","If using X-Proxy-Location, ensure the value is a supported region code."],"exampleFix":"// before\nheaders: { \"X-API-KEY\": process.env.AGENT_SERPLY_API_KEY, ... },\n// throw on non-OK\n\n// caller-side fix\nif (!process.env.AGENT_SERPLY_API_KEY) {\n  return \"AGENT_SERPLY_API_KEY is not configured.\";\n}","handlingStrategy":"validation","validationCode":"if (!process.env.AGENT_SERPLY_API_KEY) {\n  throw new Error(\"AGENT_SERPLY_API_KEY is not set. Configure it to use Serly search.\");\n}","typeGuard":null,"tryCatchPattern":"try {\n  const results = await serlySearch(query);\n  return results;\n} catch (e) {\n  if (e.message.startsWith(\"401\") || e.message.includes(\"Unauthorized\")) {\n    return \"Serly API key invalid. Check AGENT_SERLY_API_KEY.\";\n  }\n  if (e.message.startsWith(\"429\") || e.message.startsWith(\"402\")) {\n    return \"Serly rate/plan limit reached. Check your plan.\";\n  }\n  throw e;\n}","preventionTips":["Set and verify AGENT_SERLY_API_KEY before using Serly search.","Remember Serly returns 200 with {message:'Unauthorized'} for bad keys (see error 413) — check both HTTP status and body.","Validate X-Proxy-Location is a supported region if set.","Monitor plan quota to avoid mid-search failures."],"tags":["serly","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"}