{"record":{"id":"f3ba82d9ed23c385","repo":"Hmbown/CodeWhale","slug":"runtime-api-returned-status-detail","errorCode":null,"errorMessage":"runtime API returned {status}: {detail}","messagePattern":"runtime API returned (.+?): (.+?)","errorType":"http","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/app-server/src/lib.rs","lineNumber":1623,"sourceCode":"    }\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\")\n            .and_then(Value::as_array)\n            .and_then(|providers| {","sourceCodeStart":1605,"sourceCodeEnd":1641,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/app-server/src/lib.rs#L1605-L1641","documentation":"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.","triggerScenarios":"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.","commonSituations":"Sending an invalid request payload (400), auth token mismatch between app-server and runtime (401), or runtime-internal failures (5xx) with descriptive bodies.","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."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"// the detail after ': ' names the concrete problem — parse and branch on it\nif let Err(e) = call_runtime().await {\n    let msg = e.to_string();\n    if msg.contains(\"401\") { /* fix auth token */ }\n    else if msg.contains(\"400\") { /* fix request payload per detail */ }\n    else { return Err(e); }\n}","preventionTips":["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."],"tags":["http","api","runtime","error-message"],"backgroundTag":"api-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"}