{"record":{"id":"0f2b3cb39a921d37","repo":"Mintplex-Labs/anything-llm","slug":"res-status-res-statustext-params-json-0f2b3c","errorCode":null,"errorMessage":"${res.status} - ${res.statusText}. params: ${JSON.stringify({ auth: this.middleTruncate(process.env.AGENT_CRW_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":1297,"sourceCode":"                baseUrl = baseUrl.toString();\n              } catch (e) {\n                this.super.handlerProps.log(\n                  `invalid fastCRW Search URL: ${e.message}`\n                );\n              }\n            }\n\n            const { response, error } = await fetch(`${baseUrl}/v1/search`, {\n              method: \"POST\",\n              headers: {\n                \"Content-Type\": \"application/json\",\n                Authorization: `Bearer ${process.env.AGENT_CRW_API_KEY}`,\n              },\n              body: JSON.stringify({ query }),\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_CRW_API_KEY, 5), q: query })}`\n                );\n              })\n              .then((data) => {\n                if (data?.success === false)\n                  throw new Error(\n                    data?.error || \"fastCRW returned an unsuccessful response.\"\n                  );\n                return { response: data, error: null };\n              })\n              .catch((e) => {\n                this.super.handlerProps.log(\n                  `fastCRW Search Error: ${e.message}`\n                );\n                return { response: null, error: e.message };\n              });\n\n            if (error)","sourceCodeStart":1279,"sourceCodeEnd":1315,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/526360e320da9d1b36074be5ed64fe76e5bbfbbd/server/utils/agents/aibitat/plugins/web-browsing.js#L1279-L1315","documentation":"Thrown by the fastCRW search integration when the POST to `${baseUrl}/v1/search` returns a non-2xx HTTP status. The promise chain checks `res.ok` and, on failure, throws an Error embedding `res.status`, `res.statusText`, a middle-truncated `AGENT_CRW_API_KEY` (so an operator can match a key without leaking it), and the query. fastCRW is an internal/hosted search backend authenticated via a Bearer token.","triggerScenarios":"fastCRW returns 401 (AGENT_CRW_API_KEY missing/wrong), 403 (key lacks scope), 404 (baseUrl points at a host with no /v1/search), 429 (rate limit), or 5xx (fastCRW service degraded). Only fires when `res.ok === false` — a 200 with a failed body is a different error (421).","commonSituations":"AGENT_CRW_API_KEY env var unset or expired between deploys; the CRW base URL misconfigured to point at a stale or wrong host; free/quota tier exceeded; a corporate proxy returns 407/502; fastCRW itself is mid-deploy.","solutions":["Read the status code in the message and the truncated key — confirm the key in your env matches a valid fastCRW credential.","If 401/403, rotate or re-issue AGENT_CRW_API_KEY with the fastCRW provider.","If 429, back off and let the agent's outer loop retry (this error is caught by the surrounding .catch and surfaced to the LLM as a soft failure).","Verify the fastCRW base URL is reachable and is actually a fastCRW /v1/search endpoint (curl the POST with the same Bearer token).","If 5xx, check the fastCRW service health/dashboard before retrying."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Before calling fastCRW, confirm the env is wired.\nfunction assertFastCrwEnv() {\n  if (!process.env.AGENT_CRW_API_KEY)\n    throw new Error('AGENT_CRW_API_KEY is not set; fastCRW search will return 401.');\n  if (!process.env.AGENT_CRW_BASE_URL && !defaultBaseUrl)\n    throw new Error('fastCRW base URL is not configured.');\n}\n// call assertFastCrwEnv() before the fetch at web-browsing.js:1287","typeGuard":null,"tryCatchPattern":"// The surrounding .catch already converts the throw to a soft result.\n// Keep the {response, error} shape so callers never see a raw exception:\nconst { response, error } = await fetch(url, opts)\n  .then(res => res.ok ? res.json() : Promise.reject(new Error(`${res.status} ${res.statusText}`)))\n  .then(data => ({ response: data, error: null }))\n  .catch(e => ({ response: null, error: e.message }));\nif (error) return `There was an error searching for content. ${error}`;","preventionTips":["Validate AGENT_CRW_API_KEY and the CRW base URL at server boot, not only when the agent first searches.","Never log the full API key — keep the middleTruncate pattern that is already in the message.","Treat 429 as transient: let the agent retry the search rather than failing the whole turn.","Run a smoke-test search against fastCRW in your health check."],"tags":["network","search","api-auth","http-status","env-config","fastcrw"],"backgroundTag":null,"analyzedSha":"526360e320da9d1b36074be5ed64fe76e5bbfbbd","analyzedAt":"2026-08-13T01:45:47.170Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}