{"record":{"id":"dd940ef0ce0aba9d","repo":"Mintplex-Labs/anything-llm","slug":"res-status-res-statustext-params-json-dd940e","errorCode":null,"errorMessage":"${res.status} - ${res.statusText}. params: ${JSON.stringify({ auth: usingKey ? this.middleTruncate(apiKey, 5) : \"keyless\", q: query })}","messagePattern":"(.+?) - (.+?)\\. params: (.+?)\\)\\}","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"server/utils/agents/aibitat/plugins/web-browsing.js","lineNumber":1378,"sourceCode":"            );\n            searchURL.searchParams.append(\"query\", query);\n            searchURL.searchParams.append(\"count\", \"10\");\n\n            const headers = {\n              Accept: \"application/json\",\n              // Pin identity encoding: keyless endpoint can advertise gzip with\n              // body bytes that Node's decoder rejects (same workaround as LiteLLM).\n              \"Accept-Encoding\": \"identity\",\n            };\n            if (usingKey) headers[\"X-API-Key\"] = apiKey;\n\n            const { response, error } = await fetch(searchURL.toString(), {\n              method: \"GET\",\n              headers,\n            })\n              .then((res) => {\n                if (res.ok) return res.json();\n                throw new Error(\n                  `${res.status} - ${res.statusText}. params: ${JSON.stringify({\n                    auth: usingKey ? this.middleTruncate(apiKey, 5) : \"keyless\",\n                    q: query,\n                  })}`\n                );\n              })\n              .then((data) => {\n                return { response: data, error: null };\n              })\n              .catch((e) => {\n                this.super.handlerProps.log(\n                  `You.com 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}`;","sourceCodeStart":1360,"sourceCodeEnd":1396,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/526360e320da9d1b36074be5ed64fe76e5bbfbbd/server/utils/agents/aibitat/plugins/web-browsing.js#L1360-L1396","documentation":"Thrown by the You.com search integration on a non-2xx response. The code targets two endpoints: keyless GET `https://api.you.com/v1/agents/search` (free tier, no key) or keyed GET `https://ydc-index.io/v1/search` with `X-API-Key`. The message embeds status, statusText, whether the call was keyless or used a truncated key, and the query. `Accept-Encoding: identity` is pinned because You.com advertises gzip with body bytes Node's decoder rejects.","triggerScenarios":"Keyless tier returns 429 (free/shared pool exhausted — the most common case); keyed tier returns 401/403 (AGENT_YOU_API_KEY invalid/expired); 5xx from You.com; api.you.com or ydc-index.io unreachable from the host.","commonSituations":"Running keyless and hitting the shared free-tier throttle; AGENT_YOU_API_KEY set but expired or for the wrong product; egress firewall blocking api.you.com / ydc-index.io; the query string contains characters that break URL searchParams encoding.","solutions":["If keyless and seeing 429, set AGENT_YOU_API_KEY to switch to the dedicated-key endpoint (ydc-index.io).","If keyed and seeing 401/403, rotate the You.com API key.","Confirm outbound HTTPS to api.you.com (keyless) or ydc-index.io (keyed) is permitted by firewall/proxy.","On 5xx, retry — the .catch returns {response:null, error} and the agent surfaces it to the LLM as a soft failure.","URL-encode/sanitize the query before it reaches searchParams.append if it contains control characters."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// Decide keyless vs keyed up front and validate the keyed case.\nconst apiKey = process.env.AGENT_YOU_API_KEY || null;\nconst usingKey = !!apiKey;\nif (usingKey && apiKey.length < 16)\n  throw new Error('AGENT_YOU_API_KEY looks malformed; expected a full You.com API key.');","typeGuard":null,"tryCatchPattern":"// Keep the soft {response, error} contract; retry only on 429/5xx.\nconst { response, error } = await fetch(searchURL.toString(), { method: 'GET', headers })\n  .then(res => res.ok ? res.json() : Promise.reject(Object.assign(new Error(`${res.status}`), { status: res.status })))\n  .then(data => ({ response: data, error: null }))\n  .catch(e => ({ response: null, error: e }));\nif (error && (error.status === 429 || error.status >= 500)) await retryWithBackoff();","preventionTips":["If you exceed the keyless free tier regularly, set AGENT_YOU_API_KEY to move to the dedicated endpoint.","Keep `Accept-Encoding: identity` pinned — removing it reintroduces the gzip-decode failure the comment warns about.","Retry on 429/5xx but fail fast on 401/403 (key problem, not transient).","URL-sanitize the query before appending to searchParams."],"tags":["network","search","api-auth","rate-limit","youcom","http-status"],"backgroundTag":null,"analyzedSha":"526360e320da9d1b36074be5ed64fe76e5bbfbbd","analyzedAt":"2026-08-13T01:45:47.170Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}