{"record":{"id":"e01a212e72ae6a60","repo":"Mintplex-Labs/anything-llm","slug":"res-status-res-statustext-params-json-e01a21","errorCode":null,"errorMessage":"${res.status} - ${res.statusText}. params: ${JSON.stringify({ auth: this.middleTruncate(process.env.AGENT_BAIDU_SEARCH_API_KEY, 5), q: query, body: body.slice(0, 300) })}","messagePattern":"(.+?) - (.+?)\\. params: (.+?)\\)\\}","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"server/utils/agents/aibitat/plugins/web-browsing.js","lineNumber":652,"sourceCode":"              \"https://qianfan.baidubce.com/v2/ai_search/web_search\",\n              {\n                method: \"POST\",\n                headers: {\n                  \"Content-Type\": \"application/json\",\n                  Authorization: `Bearer ${process.env.AGENT_BAIDU_SEARCH_API_KEY}`,\n                  \"X-Appbuilder-Authorization\": `Bearer ${process.env.AGENT_BAIDU_SEARCH_API_KEY}`,\n                },\n                body: JSON.stringify({\n                  messages: [{ role: \"user\", content: query }],\n                  resource_type_filter: [{ type: \"web\", top_k: 10 }],\n                }),\n              }\n            )\n              .then(async (res) => {\n                if (res.ok) return res.json();\n\n                const body = await res.text().catch(() => \"\");\n                throw new Error(\n                  `${res.status} - ${res.statusText}. params: ${JSON.stringify({\n                    auth: this.middleTruncate(\n                      process.env.AGENT_BAIDU_SEARCH_API_KEY,\n                      5\n                    ),\n                    q: query,\n                    body: body.slice(0, 300),\n                  })}`\n                );\n              })\n              .then((data) => {\n                return { response: data, error: null };\n              })\n              .catch((e) => {\n                this.super.handlerProps.log(`Baidu Search Error: ${e.message}`);\n                return { response: null, error: e.message };\n              });\n","sourceCodeStart":634,"sourceCodeEnd":670,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/526360e320da9d1b36074be5ed64fe76e5bbfbbd/server/utils/agents/aibitat/plugins/web-browsing.js#L634-L670","documentation":"Thrown by the Baidu Search provider when a POST to the Baidu AppBuilder endpoint returns a non-OK status. Authentication uses AGENT_BAIDU_SEARCH_API_KEY as a Bearer token in X-Appbuilder-Authorization. Unlike other providers, this error also reads the response body (up to 300 chars) and includes it in the message, giving richer diagnostics for non-200 responses.","triggerScenarios":"Baidu returns 401 (invalid or expired Bearer token), 403 (access denied — service not activated), 429 (QPS limit), 400 (malformed request body), or 5xx. The body fragment in the error often contains Baidu's specific error code and Chinese-language message. An unset key yields an empty Bearer token.","commonSituations":"AGENT_BAIDU_SEARCH_API_KEY not set; Baidu AppBuilder service not activated for the account; key expired; QPS exceeded by concurrent agent calls; network connectivity to Baidu's servers blocked outside China.","solutions":["Read the body fragment in the error — Baidu includes a numeric error code and message that pinpoints the issue.","Verify AGENT_BAIDU_SEARCH_API_KEY is set and the AppBuilder search service is activated in the Baidu console.","A 401/403 means the token is invalid or the service is not enabled — re-issue the token and confirm activation.","Ensure network egress from the server can reach Baidu's API endpoints."],"exampleFix":"// before\n\"X-Appbuilder-Authorization\": `Bearer ${process.env.AGENT_BAIDU_SEARCH_API_KEY}`,\n\n// caller-side fix\nif (!process.env.AGENT_BAIDU_SEARCH_API_KEY) {\n  return \"AGENT_BAIDU_SEARCH_API_KEY is not configured.\";\n}","handlingStrategy":"validation","validationCode":"if (!process.env.AGENT_BAIDU_SEARCH_API_KEY) {\n  throw new Error(\"AGENT_BAIDU_SEARCH_API_KEY is not set. Configure it to use Baidu Search.\");\n}","typeGuard":null,"tryCatchPattern":"try {\n  const results = await baiduSearch(query);\n  return results;\n} catch (e) {\n  // The body fragment in the error often has the Baidu-specific error code\n  if (e.message.includes(\"401\") || e.message.includes(\"Unauthorized\")) {\n    return \"Baidu auth failed. Verify AGENT_BAIDU_SEARCH_API_KEY and that AppBuilder search is activated.\";\n  }\n  throw e;\n}","preventionTips":["Verify the Baidu AppBuilder search service is activated, not just the key issued.","Confirm network egress to Baidu API endpoints is not blocked.","Read the body fragment in the error — it contains Baidu's specific error code.","Ensure the Bearer token has no whitespace when set in the environment."],"tags":["baidu","web-search","http","api-key","agent-tool","i18n"],"backgroundTag":null,"analyzedSha":"526360e320da9d1b36074be5ed64fe76e5bbfbbd","analyzedAt":"2026-08-13T01:45:47.170Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}