Mintplex-Labs/anything-llm · error · Error

${res.status} - ${res.statusText}. params: ${JSON.stringify(

Error message

${res.status} - ${res.statusText}. params: ${JSON.stringify({ auth: this.middleTruncate(process.env.AGENT_BING_SEARCH_API_KEY, 5), q: query })}

What it means

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.

Source

Thrown at server/utils/agents/aibitat/plugins/web-browsing.js:590

              "https://api.bing.microsoft.com/v7.0/search"
            );
            searchURL.searchParams.append("q", query);

            this.super.introspect(
              `${this.caller}: Using Bing Web Search to search for "${
                query.length > 100 ? `${query.slice(0, 100)}...` : query
              }"`
            );

            const searchResponse = await fetch(searchURL, {
              headers: {
                "Ocp-Apim-Subscription-Key":
                  process.env.AGENT_BING_SEARCH_API_KEY,
              },
            })
              .then((res) => {
                if (res.ok) return res.json();
                throw new Error(
                  `${res.status} - ${res.statusText}. params: ${JSON.stringify({ auth: this.middleTruncate(process.env.AGENT_BING_SEARCH_API_KEY, 5), q: query })}`
                );
              })
              .then((data) => {
                const searchResults = data.webPages?.value || [];
                return searchResults.map((result) => ({
                  title: result.name,
                  link: result.url,
                  snippet: result.snippet,
                }));
              })
              .catch((e) => {
                this.super.handlerProps.log(
                  `Bing Web Search Error: ${e.message}`
                );
                return [];
              });

View on GitHub (pinned to 526360e320)

Solutions

  1. Confirm AGENT_BING_SEARCH_API_KEY is set and matches an active Azure Bing Search resource key.
  2. 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.
  3. A 429 means the pricing tier rate limit is exceeded — upgrade the tier or reduce search frequency.
  4. If migrating from the deprecated Bing Search v7 to a new resource, update the key.

Example fix

// before
headers: { "Ocp-Apim-Subscription-Key": process.env.AGENT_BING_SEARCH_API_KEY },
// throw on non-OK

// caller-side fix
if (!process.env.AGENT_BING_SEARCH_API_KEY) {
  return "AGENT_BING_SEARCH_API_KEY is not configured.";
}
Defensive patterns

Strategy: validation

Validate before calling

if (!process.env.AGENT_BING_SEARCH_API_KEY) {
  throw new Error("AGENT_BING_SEARCH_API_KEY is not set. Configure it to use Bing Search.");
}

Try / catch

try {
  const results = await bingSearch(query);
  return results;
} catch (e) {
  if (e.message.startsWith("401") || e.message.startsWith("403")) {
    return "Bing Search key invalid or access denied. Verify the Azure resource and AGENT_BING_SEARCH_API_KEY.";
  }
  if (e.message.startsWith("429")) {
    // back off and retry once
    await new Promise(r => setTimeout(r, 5000));
    return await bingSearch(query);
  }
  throw e;
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of Mintplex-Labs/anything-llm@526360e320 (2026-08-13). Data as JSON: /api/errors/5fab5e5ad16801b7. Report an issue: GitHub.