Hmbown/CodeWhale · error · anyhow::Error
runtime API returned
Error message
runtime API returned {status}: {detail} What it means
Same as the plain `runtime API returned {status}` error, but the response body was non-empty, so its trimmed content is appended as `detail` to aid debugging. The runtime explicitly reported an error message for the failed request.
Solutions
- Read the `detail` suffix in the message — it usually names the exact problem (invalid field, bad token, missing route).
- Fix the request payload or auth token accordingly.
- For 5xx details, check runtime logs and upgrade or restart the Runtime.
Defensive patterns
Strategy: try-catch
Try / catch
// the detail after ': ' names the concrete problem — parse and branch on it
if let Err(e) = call_runtime().await {
let msg = e.to_string();
if msg.contains("401") { /* fix auth token */ }
else if msg.contains("400") { /* fix request payload per detail */ }
else { return Err(e); }
} Prevention
- Keep app-server and Runtime auth tokens in sync from one secret source.
- Validate request payloads against the Runtime API schema before sending.
- Read the `detail` suffix first — it is the runtime's own diagnosis.
When it happens
Trigger: A Runtime API call gets `!status.is_success()` and `body.trim()` is non-empty; e.g. 400 with a JSON error message, 401 unauthorized with a reason, 500 with a panic trace.
Common situations: Sending an invalid request payload (400), auth token mismatch between app-server and runtime (401), or runtime-internal failures (5xx) with descriptive bodies.
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/f3ba82d9ed23c385.
Report an issue: GitHub.
Appendix: source
Thrown at crates/app-server/src/lib.rs:1623
}
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")
.and_then(Value::as_array)
.and_then(|providers| {View on GitHub (pinned to 73e0f67d83)