{"record":{"id":"dcefd1caf719c807","repo":"Hmbown/CodeWhale","slug":"runtime-api-returned-status","errorCode":null,"errorMessage":"runtime API returned {status}","messagePattern":"runtime API returned (.+?)","errorType":"http","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/app-server/src/lib.rs","lineNumber":1621,"sourceCode":"            }\n        }\n    }\n\n    fn authed(&self, builder: reqwest::RequestBuilder) -> reqwest::RequestBuilder {\n        match self.auth_token.as_deref() {\n            Some(token) => builder.bearer_auth(token),\n            None => builder,\n        }\n    }\n\n    async fn request_json(&self, builder: reqwest::RequestBuilder) -> Result<Value> {\n        let response = builder.send().await?;\n        let status = response.status();\n        let body = response.text().await?;\n        if !status.is_success() {\n            let detail = body.trim();\n            if detail.is_empty() {\n                bail!(\"runtime API returned {status}\");\n            }\n            bail!(\"runtime API returned {status}: {detail}\");\n        }\n        serde_json::from_str(&body).with_context(|| format!(\"invalid runtime API json: {body}\"))\n    }\n\n    /// Read the existing Runtime catalog before a one-shot prompt can create\n    /// its thread. Existing threads are checked by canonical turn admission.\n    async fn require_output_limited_model(&self, requested_model: Option<&str>) -> Result<()> {\n        let providers = self\n            .request_json(self.authed(self.client.get(format!(\"{}/v1/providers\", self.base_url))))\n            .await?;\n        let current = providers\n            .get(\"current\")\n            .and_then(Value::as_str)\n            .context(\"Runtime provider is unavailable\")?;\n        let provider = providers\n            .get(\"providers\")","sourceCodeStart":1603,"sourceCodeEnd":1639,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/app-server/src/lib.rs#L1603-L1639","documentation":"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.","triggerScenarios":"Any Runtime API request (via the internal reqwest client helper) resolves with `!status.is_success()` and the trimmed response body is empty.","commonSituations":"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.","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."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"match result {\n    Err(e) if e.to_string().starts_with(\"runtime API returned\") => {\n        let status = extract_status(&e.to_string());\n        match status {\n            404 | 405 => /* runtime too old; upgrade or skip feature */,\n            5xx => /* restart/inspect runtime */,\n            _ => /* propagate */,\n        }\n    }\n    Err(e) => return Err(e),\n    Ok(v) => Ok(v),\n}","preventionTips":["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."],"tags":["http","api","runtime","empty-response-body"],"backgroundTag":"http-error-response","analyzedSha":"73e0f67d83c59909b571efdfc88c4bc28c309cb1","analyzedAt":"2026-09-22T01:30:00.501Z","contentChangedAt":"2026-09-22T01:30:00.501Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}