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_BAIDU_SEARCH_API_KEY, 5), q: query, body: body.slice(0, 300) })} What it means
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.
Source
Thrown at server/utils/agents/aibitat/plugins/web-browsing.js:652
"https://qianfan.baidubce.com/v2/ai_search/web_search",
{
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${process.env.AGENT_BAIDU_SEARCH_API_KEY}`,
"X-Appbuilder-Authorization": `Bearer ${process.env.AGENT_BAIDU_SEARCH_API_KEY}`,
},
body: JSON.stringify({
messages: [{ role: "user", content: query }],
resource_type_filter: [{ type: "web", top_k: 10 }],
}),
}
)
.then(async (res) => {
if (res.ok) return res.json();
const body = await res.text().catch(() => "");
throw new Error(
`${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),
})}`
);
})
.then((data) => {
return { response: data, error: null };
})
.catch((e) => {
this.super.handlerProps.log(`Baidu Search Error: ${e.message}`);
return { response: null, error: e.message };
});
View on GitHub (pinned to 526360e320)
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.
Example fix
// before
"X-Appbuilder-Authorization": `Bearer ${process.env.AGENT_BAIDU_SEARCH_API_KEY}`,
// caller-side fix
if (!process.env.AGENT_BAIDU_SEARCH_API_KEY) {
return "AGENT_BAIDU_SEARCH_API_KEY is not configured.";
} Defensive patterns
Strategy: validation
Validate before calling
if (!process.env.AGENT_BAIDU_SEARCH_API_KEY) {
throw new Error("AGENT_BAIDU_SEARCH_API_KEY is not set. Configure it to use Baidu Search.");
} Try / catch
try {
const results = await baiduSearch(query);
return results;
} catch (e) {
// The body fragment in the error often has the Baidu-specific error code
if (e.message.includes("401") || e.message.includes("Unauthorized")) {
return "Baidu auth failed. Verify AGENT_BAIDU_SEARCH_API_KEY and that AppBuilder search is activated.";
}
throw e;
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- ${res.status} - ${res.statusText}. params: ${JSON.stringify(
- ${res.status} - ${res.statusText}. params: ${JSON.stringify(
- ${res.status} - ${res.statusText}. params: ${JSON.stringify(
- ${res.status} - ${res.statusText}. params: ${JSON.stringify(
- ${res.status} - ${res.statusText}. params: ${JSON.stringify(
AI-assisted analysis of Mintplex-Labs/anything-llm@526360e320 (2026-08-13).
Data as JSON: /api/errors/e01a212e72ae6a60.
Report an issue: GitHub.