Hmbown/CodeWhale · error · anyhow::Error
runtime API returned
Error message
runtime API returned {status} What it means
Generic wrapper for any non-success HTTP status returned by the Runtime API when the response body is empty. The status line (e.g. `500 Internal Server Error`) is surfaced so the caller knows what the runtime said even without a body. A non-empty body produces the richer variant instead.
Solutions
- Check the runtime version — the endpoint may not exist in that build (upgrade the Runtime).
- Reproduce with curl against base_url to see the status directly.
- Inspect runtime logs at the time of the request for the underlying failure.
Defensive patterns
Strategy: try-catch
Try / catch
match result {
Err(e) if e.to_string().starts_with("runtime API returned") => {
let status = extract_status(&e.to_string());
match status {
404 | 405 => /* runtime too old; upgrade or skip feature */,
5xx => /* restart/inspect runtime */,
_ => /* propagate */,
}
}
Err(e) => return Err(e),
Ok(v) => Ok(v),
} Prevention
- Pin compatible app-server and Runtime versions.
- Monitor runtime health continuously rather than discovering dead endpoints per-request.
- Log full base_url + path for each API call so empty-body failures are reproducible.
When it happens
Trigger: Any Runtime API request (via the internal reqwest client helper) resolves with `!status.is_success()` and the trimmed response body is empty.
Common situations: Runtime crashed and its reverse proxy or listener returned a bare status; endpoints returning 404/405 with empty bodies when the runtime version lacks an API route.
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
- ${compactRuntimeError(response.status, result)}
- runtime API returned
- Anthropic API error (HTTP )
- Cloud agent sandbox listing failed
- Cloudflare SQL request failed
AI-assisted analysis of Hmbown/CodeWhale@73e0f67d83 (2026-09-22).
Data as JSON: /api/errors/dcefd1caf719c807.
Report an issue: GitHub.
Appendix: source
Thrown at crates/app-server/src/lib.rs:1621
}
}
}
fn authed(&self, builder: reqwest::RequestBuilder) -> reqwest::RequestBuilder {
match self.auth_token.as_deref() {
Some(token) => builder.bearer_auth(token),
None => builder,
}
}
async fn request_json(&self, builder: reqwest::RequestBuilder) -> Result<Value> {
let response = builder.send().await?;
let status = response.status();
let body = response.text().await?;
if !status.is_success() {
let detail = body.trim();
if detail.is_empty() {
bail!("runtime API returned {status}");
}
bail!("runtime API returned {status}: {detail}");
}
serde_json::from_str(&body).with_context(|| format!("invalid runtime API json: {body}"))
}
/// Read the existing Runtime catalog before a one-shot prompt can create
/// its thread. Existing threads are checked by canonical turn admission.
async fn require_output_limited_model(&self, requested_model: Option<&str>) -> Result<()> {
let providers = self
.request_json(self.authed(self.client.get(format!("{}/v1/providers", self.base_url))))
.await?;
let current = providers
.get("current")
.and_then(Value::as_str)
.context("Runtime provider is unavailable")?;
let provider = providers
.get("providers")View on GitHub (pinned to 73e0f67d83)