{"record":{"id":"5fab5e5ad16801b7","repo":"Mintplex-Labs/anything-llm","slug":"res-status-res-statustext-params-json-5fab5e","errorCode":null,"errorMessage":"${res.status} - ${res.statusText}. params: ${JSON.stringify({ auth: this.middleTruncate(process.env.AGENT_BING_SEARCH_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":590,"sourceCode":"              \"https://api.bing.microsoft.com/v7.0/search\"\n            );\n            searchURL.searchParams.append(\"q\", query);\n\n            this.super.introspect(\n              `${this.caller}: Using Bing Web Search to search for \"${\n                query.length > 100 ? `${query.slice(0, 100)}...` : query\n              }\"`\n            );\n\n            const searchResponse = await fetch(searchURL, {\n              headers: {\n                \"Ocp-Apim-Subscription-Key\":\n                  process.env.AGENT_BING_SEARCH_API_KEY,\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_BING_SEARCH_API_KEY, 5), q: query })}`\n                );\n              })\n              .then((data) => {\n                const searchResults = data.webPages?.value || [];\n                return searchResults.map((result) => ({\n                  title: result.name,\n                  link: result.url,\n                  snippet: result.snippet,\n                }));\n              })\n              .catch((e) => {\n                this.super.handlerProps.log(\n                  `Bing Web Search Error: ${e.message}`\n                );\n                return [];\n              });\n","sourceCodeStart":572,"sourceCodeEnd":608,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/526360e320da9d1b36074be5ed64fe76e5bbfbbd/server/utils/agents/aibitat/plugins/web-browsing.js#L572-L608","documentation":"Thrown by the Bing Search provider when fetch() to the Bing Web Search endpoint returns a non-OK status. Authentication uses AGENT_BING_SEARCH_API_KEY in the Ocp-Apim-Subscription-Key header (Azure-style). The error captures status, statusText, a truncated key, and the (possibly truncated to 100 chars) query. The .catch logs and the search returns an empty array on failure.","triggerScenarios":"Bing/Azure returns 401 (invalid subscription key), 403 (key valid but access denied — wrong pricing tier, region restriction), 429 (rate limit per the tier), or 5xx. An unset key sends an empty Ocp-Apim-Subscription-Key header, always producing 401.","commonSituations":"Azure resource key rotated but env not updated; Bing Search resource deprecated or migrated; free tier rate limit hit; key belongs to a different Azure subscription without Bing access; corporate firewall blocking the Azure endpoint.","solutions":["Confirm AGENT_BING_SEARCH_API_KEY is set and matches an active Azure Bing Search resource key.","A 401/403 means the key is invalid or lacks permission — verify in the Azure portal that the resource is Bing Search (not another cognitive service) and the key is correct.","A 429 means the pricing tier rate limit is exceeded — upgrade the tier or reduce search frequency.","If migrating from the deprecated Bing Search v7 to a new resource, update the key."],"exampleFix":"// before\nheaders: { \"Ocp-Apim-Subscription-Key\": process.env.AGENT_BING_SEARCH_API_KEY },\n// throw on non-OK\n\n// caller-side fix\nif (!process.env.AGENT_BING_SEARCH_API_KEY) {\n  return \"AGENT_BING_SEARCH_API_KEY is not configured.\";\n}","handlingStrategy":"validation","validationCode":"if (!process.env.AGENT_BING_SEARCH_API_KEY) {\n  throw new Error(\"AGENT_BING_SEARCH_API_KEY is not set. Configure it to use Bing Search.\");\n}","typeGuard":null,"tryCatchPattern":"try {\n  const results = await bingSearch(query);\n  return results;\n} catch (e) {\n  if (e.message.startsWith(\"401\") || e.message.startsWith(\"403\")) {\n    return \"Bing Search key invalid or access denied. Verify the Azure resource and AGENT_BING_SEARCH_API_KEY.\";\n  }\n  if (e.message.startsWith(\"429\")) {\n    // back off and retry once\n    await new Promise(r => setTimeout(r, 5000));\n    return await bingSearch(query);\n  }\n  throw e;\n}","preventionTips":["Ensure the Azure resource is specifically a Bing Search v7 resource (not a generic Cognitive Services key).","Verify AGENT_BING_SEARCH_API_KEY is set and matches the correct resource key.","Monitor rate limit usage relative to the pricing tier.","Handle 403 (access denied) separately from 401 (wrong key) — it often means the wrong resource type."],"tags":["bing-search","azure","web-search","http","api-key","agent-tool"],"backgroundTag":null,"analyzedSha":"526360e320da9d1b36074be5ed64fe76e5bbfbbd","analyzedAt":"2026-08-13T01:45:47.170Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}