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

inbound attachment exceeds

Error message

inbound attachment exceeds {} MB limit

What it means

The WeChat channel enforces a hard inbound attachment cap: after fully reading the downloaded bytes it compares the length against WECHAT_MEDIA_MAX_BYTES (100 MB, defined as 100 * 1024 * 1024 at wechat.rs:74) and bails when exceeded. The message interpolates the limit in MB (100). It protects the process from buffering unbounded media in memory.

Solutions

  1. Reply to the sender that the file exceeds the bot's 100 MB limit and ask for a link instead
  2. If larger inbound media is genuinely required, raise WECHAT_MEDIA_MAX_BYTES in crates/zeroclaw-channels/src/wechat.rs (line ~74) and rebuild, after confirming the memory budget can absorb larger buffers
  3. Handle the error per-attachment so the rest of the message (text, smaller parts) is still processed

Example fix

// before (crates/zeroclaw-channels/src/wechat.rs)
const WECHAT_MEDIA_MAX_BYTES: u64 = 100 * 1024 * 1024;
// after (deliberately raise the cap, then rebuild)
const WECHAT_MEDIA_MAX_BYTES: u64 = 200 * 1024 * 1024;
Defensive patterns

Strategy: validation

Validate before calling

// Pre-check the size reported in the inbound message metadata before triggering the download
const WECHAT_MEDIA_MAX_BYTES: u64 = 100 * 1024 * 1024;
if let Some(size) = inbound.attachment_reported_size() {
    if size as u64 > WECHAT_MEDIA_MAX_BYTES {
        reply(chat, "File too large for this bot (max 100 MB). Please share a link.").await;
        return Ok(());
    }
}

Try / catch

Catch the 'inbound attachment exceeds' bail per attachment, reply with a size-limit notice, and continue processing the rest of the message.

Prevention

When it happens

Trigger: Any inbound WeChat attachment whose downloaded byte length exceeds 100 MB — typically large videos or file transfers forwarded to the bot.

Common situations: Users sending HD video files or archives; forwarding WeChat files that can be far larger than the bot cap; the limit is a compile-time constant, so changing it requires editing the crate and rebuilding.

Understand the failure class

Background: "File too large" / "file size exceeds limit" errors: why libraries cap file sizes and how to fix them — this error's family across 46 libraries.

Related errors


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

Appendix: source

Thrown at crates/zeroclaw-channels/src/wechat.rs:1559

        &self,
        spec: &InboundAttachmentSpec,
    ) -> anyhow::Result<Vec<u8>> {
        let resp = self
            .client
            .get(self.cdn_download_url(&spec.encrypted_query_param))
            .timeout(API_TIMEOUT)
            .send()
            .await?;

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

        let bytes = resp.bytes().await?.to_vec();
        if bytes.len() as u64 > WECHAT_MEDIA_MAX_BYTES {
            anyhow::bail!(
                "inbound attachment exceeds {} MB limit",
                WECHAT_MEDIA_MAX_BYTES / (1024 * 1024)
            );
        }

        match spec.aes_key.as_deref() {
            Some(aes_key) if !aes_key.is_empty() => {
                let key = parse_aes_key(aes_key)?;
                decrypt_aes_ecb(&bytes, &key)
            }
            _ => Ok(bytes),
        }
    }

    async fn try_build_attachment_content(
        &self,
        items: &[serde_json::Value],
        message_id: &str,

View on GitHub (pinned to 88bb9c8533)