{"record":{"id":"1989a90822d02b63","repo":"zeroclaw-labs/zeroclaw","slug":"stability-ai-failed-status-body-text","errorCode":null,"errorMessage":"Stability AI failed ({status}): {body_text}","messagePattern":"Stability AI failed \\((.+?)\\): (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/zeroclaw-tools/src/linkedin_client.rs","lineNumber":969,"sourceCode":"            \"width\": 1024,\n            \"samples\": 1,\n            \"steps\": 30\n        });\n\n        let resp = client\n            .post(&url)\n            .header(\"Authorization\", format!(\"Bearer {api_key}\"))\n            .header(\"Content-Type\", \"application/json\")\n            .header(\"Accept\", \"application/json\")\n            .json(&body)\n            .send()\n            .await\n            .context(\"Stability AI request failed\")?;\n\n        let status = resp.status();\n        if !status.is_success() {\n            let body_text = resp.text().await.unwrap_or_default();\n            anyhow::bail!(\"Stability AI failed ({status}): {body_text}\");\n        }\n\n        let json: serde_json::Value = resp.json().await?;\n        let b64 = json\n            .pointer(\"/artifacts/0/base64\")\n            .and_then(|v| v.as_str())\n            .ok_or_else(|| {\n                ::zeroclaw_log::record!(\n                    ERROR,\n                    ::zeroclaw_log::Event::new(module_path!(), ::zeroclaw_log::Action::Fail)\n                        .with_outcome(::zeroclaw_log::EventOutcome::Failure)\n                        .with_attrs(::serde_json::json!({\"image_provider\": \"stability\"})),\n                    \"linkedin_client: Stability response missing image data\"\n                );\n                anyhow::Error::msg(\"No image data in Stability response\")\n            })?;\n\n        let bytes = base64_decode(b64)?;","sourceCodeStart":951,"sourceCodeEnd":987,"githubUrl":"https://github.com/zeroclaw-labs/zeroclaw/blob/88bb9c8533fc57ed7a03e36ca7c9ed2bf8336dcc/crates/zeroclaw-tools/src/linkedin_client.rs#L951-L987","documentation":"try_stability sends the prompt to the Stability AI REST API and bails on any non-2xx status, embedding the status and response body. It runs only after read_env_var found the configured Stability key, so a failure here is about the request or response, not key configuration.","triggerScenarios":"401/403 with an invalid or revoked Stability key; 400 for an unsupported engine id, aspect ratio, or output parameter; 402/429 when credits are exhausted or the org is throttled; connection failures through restricted egress proxies.","commonSituations":"Rotated keys not updated in the workspace .env; free-tier credits exhausted mid-campaign; changing the engine id to one the account cannot access.","solutions":["Read body_text — Stability returns a message naming the invalid parameter or the auth problem","Update the Stability key in .env if the status is 401/403","Check billing and credits on 402, and back off on 429","Keep a second provider (dalle, imagen, flux) in the providers list so generate() can fall through automatically"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"You rarely catch this directly: generate() already swallows per-provider failures and moves on. Catch generate()'s terminal error instead and act on the earlier WARN logs that carry the Stability status and body.","preventionTips":["Configure a second provider after stability in the providers list","Monitor Stability credit balance before scheduled runs","Keep the key in the env var named by stability.api_key_env current"],"tags":["stability-ai","image-generation","http","api-key"],"backgroundTag":"image-generation-api-error","analyzedSha":"88bb9c8533fc57ed7a03e36ca7c9ed2bf8336dcc","analyzedAt":"2026-08-23T01:07:41.857Z","schemaVersion":2},"datasetVersion":"2026-08-23T08:06:27.607Z"}