datawhalechina/hello-agents · error
研究请求失败,状态码:
Error message
研究请求失败,状态码:${response.status} What it means
Thrown by the SSE streaming client for POST /research/stream when the HTTP response status is not OK. It first tries to read the body as text and use it as the message; only when the body is unreadable/empty does it throw the template literal containing the status code. So seeing this exact templated message means the server returned an error with an empty or unreadable body.
Solutions
- Reproduce with curl -i -X POST ${baseURL}/research/stream -H 'Content-Type: application/json' -d '<payload>' to see the real status and body
- If 422, log the request payload and compare against the backend Pydantic model for the endpoint
- If 502/504 from a proxy, raise proxy read/idle timeouts because SSE streams hold the connection open
- Confirm baseURL resolves (check vite proxy or absolute URL) and the backend service is up
Defensive patterns
Strategy: validation
Validate before calling
if (!payload || typeof payload !== 'object') throw new Error('payload required'); Type guard
function isResearchPayload(p) { return typeof p === 'object' && p !== null && 'query' in p; } Try / catch
try { const stream = await startResearchStream(payload); } catch (e) { showBanner(e.message); disableStreamUI(); } Prevention
- Contract-test the /research/stream schema on both sides
- Log response.status alongside message
- Keep proxy read timeouts above the longest research run
When it happens
Trigger: POST to ${baseURL}/research/stream returning 422 (payload validation failed), 401, 500 from the agent backend, or 502/504 from a reverse proxy with an empty body. Also happens when baseURL points to the wrong host and an edge returns a bare error status.
Common situations: Payload shape mismatch with the backend schema (missing required fields like query/topic), long-running research task killed by proxy idle timeout, backend not started, wrong vite proxy config for the /research path in dev.
Related errors
AI-assisted analysis of datawhalechina/hello-agents@606a07d341 (2026-08-14).
Data as JSON: /api/errors/adeeef400a8e6e5e.
Report an issue: GitHub.
Appendix: source
Thrown at Co-creation-projects/JJason-DeepCastAgent/frontend/src/services/api.ts:45
export async function runResearchStream(
payload: ResearchRequest,
onEvent: (event: ResearchStreamEvent) => void,
options: StreamOptions = {}
): Promise<void> {
const response = await fetch(`${baseURL}/research/stream`, {
method: "POST",
headers: {
"Content-Type": "application/json",
Accept: "text/event-stream"
},
body: JSON.stringify(payload),
signal: options.signal
});
if (!response.ok) {
const errorText = await response.text().catch(() => "");
throw new Error(
errorText || `研究请求失败,状态码:${response.status}`
);
}
const body = response.body;
if (!body) {
throw new Error("浏览器不支持流式响应,无法获取研究进度");
}
const reader = body.getReader();
const decoder = new TextDecoder("utf-8");
let buffer = "";
while (true) {
const { value, done } = await reader.read();
buffer += decoder.decode(value || new Uint8Array(), { stream: !done });
let boundary = buffer.indexOf("\n\n");View on GitHub (pinned to 606a07d341)