zed-industries/zed · error
Request failed with status: {:?} Body: {}
Error message
Request failed with status: {:?}
Body: {} What it means
Mercury completion request handling: after reading the body, any non-2xx status that is not 402 (which gets the dedicated payment error) bails with the debug-formatted status and the lossy-UTF-8 body (mercury.rs:188). The body is Mercury's error payload and is the key to diagnosing the failure.
Source
Thrown at crates/edit_prediction/src/mercury.rs:188
.send(request)
.await
.context("Failed to send request")?;
let mut body: Vec<u8> = Vec::new();
response
.body_mut()
.read_to_end(&mut body)
.await
.context("Failed to read response body")?;
if !response.status().is_success() {
if response.status() == StatusCode::PAYMENT_REQUIRED {
anyhow::bail!(MercuryPaymentRequiredError(
mercury_payment_required_message(&body),
));
}
anyhow::bail!(
"Request failed with status: {:?}\nBody: {}",
response.status(),
String::from_utf8_lossy(&body),
);
};
let mut response: open_ai::Response =
serde_json::from_slice(&body).context("Failed to parse response")?;
let id = mem::take(&mut response.id);
let response_str = text_from_response(response).unwrap_or_default();
if let Some(debug_tx) = &debug_tx {
debug_tx
.unbounded_send(DebugEvent::EditPredictionFinished(
EditPredictionFinishedDebugEvent {
buffer: active_buffer.downgrade(),
model_output: Some(response_str.clone()),View on GitHub (pinned to f4178619ac)
Solutions
- For 401, trigger a credential refresh (sign out/in) so a valid Bearer token is sent.
- For 429, pause prediction usage and retry after the limit resets.
- For 5xx, retry later; check Zed status for incidents.
- Read the Body field — if it is HTML from a proxy, fix network egress instead of auth.
Defensive patterns
Strategy: retry
Try / catch
Branch on the embedded status: 401 → stop and refresh credentials; 429/5xx → retry with backoff; log the body verbatim (it may be JSON or proxy HTML, which itself distinguishes network from API failure).
Prevention
- Refresh credentials proactively when tokens have a known TTL.
- Read the body before assuming API fault — HTML bodies point at proxies.
- Log request ids to correlate with server-side incidents.
When it happens
Trigger: The Mercury API returning 401 (invalid/expired bearer token loaded from the credentials store), 429 (rate limited), 5xx (service incident), or an HTML error page from a proxy in front of the endpoint.
Common situations: Stale credentials after token rotation; heavy prediction usage hitting rate limits; Zed-side incidents; corporate proxies returning their own error pages instead of the API response.
Understand the failure class
Background: "API error: {status}" and "HTTP 401/403/404/429/5xx" errors: non-2xx HTTP responses explained — this error's family across 27 libraries.
Related errors
- Request failed with status: {status:?} Body: {body}
- Failed to fetch experiments: {:?} Body: {}
- Feedback API returned status: {}
- missing Content-Type header
- Failed to connect to DeepSeek API: {} {}
AI-assisted analysis of zed-industries/zed@f4178619ac (2026-08-20).
Data as JSON: /api/errors/7a16914c91909118.
Report an issue: GitHub.