zeroclaw-labs/zeroclaw · error · anyhow::Error

Flux failed ({status}): {body_text}

Error message

Flux failed ({status}): {body_text}

What it means

try_flux sends the prompt to the configured Flux REST endpoint and bails on any non-2xx status with the body embedded. The Flux key was already read from .env, so this error is the provider's HTTP-level response: auth, subscription/credits, queue pressure, or upstream failure.

Source

Thrown at crates/zeroclaw-tools/src/linkedin_client.rs:1146

        let body = json!({
            "prompt": prompt,
            "image_size": "square_hd",
            "num_images": 1
        });

        let resp = client
            .post(&url)
            .header("Authorization", format!("Key {api_key}"))
            .header("Content-Type", "application/json")
            .json(&body)
            .send()
            .await
            .context("Flux request failed")?;

        let status = resp.status();
        if !status.is_success() {
            let body_text = resp.text().await.unwrap_or_default();
            anyhow::bail!("Flux failed ({status}): {body_text}");
        }

        let json: serde_json::Value = resp.json().await?;
        let image_url = json
            .pointer("/images/0/url")
            .and_then(|v| v.as_str())
            .ok_or_else(|| {
                ::zeroclaw_log::record!(
                    ERROR,
                    ::zeroclaw_log::Event::new(module_path!(), ::zeroclaw_log::Action::Fail)
                        .with_outcome(::zeroclaw_log::EventOutcome::Failure)
                        .with_attrs(::serde_json::json!({"image_provider": "flux"})),
                    "linkedin_client: Flux response missing image URL"
                );
                anyhow::Error::msg("No image URL in Flux response")
            })?;

        // Download the image from the returned URL

View on GitHub (pinned to 88bb9c8533)

Solutions

  1. Read the embedded body_text to classify: auth vs billing vs queue vs upstream
  2. Update the key in the env var named by the flux api_key_env config on 401/402
  3. Back off and retry later on 429 — queue pressure is transient
  4. Keep another provider earlier in the providers list so generate() falls through instead of failing the post
Defensive patterns

Strategy: fallback

Try / catch

Per-provider failure consumed by generate(); on terminal failure, read the WARN log for the Flux status/body and either fix the subscription/key or wait out queue pressure (429).

Prevention

When it happens

Trigger: 401/402 with an invalid key or exhausted subscription; 429 when the generation queue is saturated; 5xx from upstream model failures; malformed generation parameters rejected as 400.

Common situations: Flux API keys with expired subscriptions; burst posting hitting queue limits; regional endpoints unreachable from the deployment network.

Related errors


AI-assisted analysis of zeroclaw-labs/zeroclaw@88bb9c8533 (2026-08-23). Data as JSON: /api/errors/1a668a3a31216373. Report an issue: GitHub.