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

chat.postMessage failed

Error message

chat.postMessage failed: {err}

What it means

Raised when chat.postMessage returned HTTP 200 but the parsed body has ok=false. The {err} value is Slack's error field from the response JSON (for example channel_not_found or not_in_channel), indicating Slack refused the otherwise well-formed request.

Solutions

  1. Check network connectivity to Slack and the error detail; verify the bot token is valid.
Defensive patterns

Strategy: retry

When it happens

Trigger: Thrown at crates/zeroclaw-channels/src/slack.rs:1265 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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

Appendix: source

Thrown at crates/zeroclaw-channels/src/slack.rs:1265

        let status = resp.status();
        let raw = resp
            .text()
            .await
            .unwrap_or_else(|e| format!("<failed to read response body: {e}>"));

        if !status.is_success() {
            let sanitized = zeroclaw_providers::sanitize_api_error(&raw);
            anyhow::bail!("chat.postMessage failed ({status}): {sanitized}");
        }

        let parsed: serde_json::Value = serde_json::from_str(&raw).unwrap_or_default();
        if parsed.get("ok") == Some(&serde_json::Value::Bool(false)) {
            let err = parsed
                .get("error")
                .and_then(|e| e.as_str())
                .unwrap_or("unknown");
            anyhow::bail!("chat.postMessage failed: {err}");
        }

        parsed
            .get("ts")
            .and_then(|v| v.as_str())
            .map(String::from)
            .ok_or_else(|| {
                ::zeroclaw_log::record!(
                    WARN,
                    ::zeroclaw_log::Event::new(module_path!(), ::zeroclaw_log::Action::Reject)
                        .with_outcome(::zeroclaw_log::EventOutcome::Failure)
                        .with_attrs(
                            ::serde_json::json!({"field": "ts", "api": "chat.postMessage"})
                        ),
                    "slack: chat.postMessage response missing ts"
                );
                anyhow::Error::msg("chat.postMessage response missing 'ts'")
            })

View on GitHub (pinned to 88bb9c8533)