{"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":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/utils/agents/aibitat/plugins/web-browsing.js","lineNumber":658,"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":640,"sourceCodeEnd":676,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/a145d4d87d086bdb31d50f9bf9cd9c46d311780c/server/utils/agents/aibitat/plugins/web-browsing.js#L640-L676","documentation":"Thrown inside the Baidu AppBuilder search branch of the web-browsing plugin when the POST (X-Appbuilder-Authorization: Bearer AGENT_BAIDU_SEARCH_API_KEY, body with a user message and resource_type_filter web/top_k 10) returns non-ok. Unlike the siblings, it first reads the response body and includes its first 300 characters in the message alongside status, statusText, query, and the truncated key. The surrounding .catch converts it to a logged 'Baidu Search Error' and an error string for the agent.","triggerScenarios":"AGENT_BAIDU_SEARCH_API_KEY missing/invalid (401); AppBuilder QPS or quota limits exceeded (429); malformed request body such as a bad resource_type_filter (400); regional/service unavailability (5xx). Body text in the message pinpoints the API's own error code/description.","commonSituations":"AppBuilder key expired or the app deleted; using an ERNIE Bot key instead of an AppBuilder access key; .env updated without process restart; QPS spikes when the agent fans out multiple searches.","solutions":["Set AGENT_BAIDU_SEARCH_API_KEY to a valid Baidu AppBuilder API key and restart the server.","Read the embedded body snippet for Baidu's specific error code (auth vs quota vs param) and act on it.","For 429s, reduce concurrent web_search calls or add backoff; check the AppBuilder console for quota."],"exampleFix":"# before\nAGENT_BAIDU_SEARCH_API_KEY=<ernie-bot-key>  # 401 - Unauthorized\n\n# after\nAGENT_BAIDU_SEARCH_API_KEY=<appbuilder access key>\n# restart server","handlingStrategy":"validation","validationCode":"const KEY = process.env.AGENT_BAIDU_SEARCH_API_KEY;\nif (!KEY) throw new Error(\"AGENT_BAIDU_SEARCH_API_KEY not set — configure it and restart\");\n// pre-flight the AppBuilder endpoint cheaply:\nconst r = await fetch(\"https://qianfan.baidubce.com/v2/app\", {\n  headers: { \"X-Appbuilder-Authorization\": `Bearer ${KEY}` },\n});\nif (r.status === 401) throw new Error(\"Baidu AppBuilder key rejected (401)\");","typeGuard":null,"tryCatchPattern":"const out = await webSearch(query);\nif (typeof out === \"string\" && out.includes(\"Baidu Search Error\")) {\n  // message carries the first 300 chars of Baidu's response body — parse its error code there\n  if (/\"code\":\\s*401|Unauthorized/i.test(out)) rotateBaiduKey();\n  else if (out.includes(\"429\") || /QPS|limit/i.test(out)) backoffThenRetry(query);\n  else logForInspection(out);\n}","preventionTips":["Use an AppBuilder access key, not an ERNIE/Qianfan model key, in AGENT_BAIDU_SEARCH_API_KEY.","Respect AppBuilder QPS limits — serialize agent searches instead of fanning out.","Exploit the embedded body snippet: Baidu's numeric error codes identify auth vs quota vs param faults precisely."],"tags":["web-search","baidu","http-error","api-key","agent-tools"],"backgroundTag":"search-api-http-error","analyzedSha":"a145d4d87d086bdb31d50f9bf9cd9c46d311780c","analyzedAt":"2026-08-18T10:02:21.017Z","contentChangedAt":"2026-08-18T10:02:21.017Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}