{"record":{"id":"502cea474e2983b7","repo":"zeroclaw-labs/zeroclaw","slug":"inbound-attachment-exceeds-mb-limit","errorCode":null,"errorMessage":"inbound attachment exceeds {} MB limit","messagePattern":"inbound attachment exceeds (.+?) MB limit","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/zeroclaw-channels/src/wechat.rs","lineNumber":1559,"sourceCode":"        &self,\n        spec: &InboundAttachmentSpec,\n    ) -> anyhow::Result<Vec<u8>> {\n        let resp = self\n            .client\n            .get(self.cdn_download_url(&spec.encrypted_query_param))\n            .timeout(API_TIMEOUT)\n            .send()\n            .await?;\n\n        if !resp.status().is_success() {\n            let status = resp.status();\n            let body = resp.text().await.unwrap_or_default();\n            anyhow::bail!(\"attachment download failed ({status}): {body}\");\n        }\n\n        let bytes = resp.bytes().await?.to_vec();\n        if bytes.len() as u64 > WECHAT_MEDIA_MAX_BYTES {\n            anyhow::bail!(\n                \"inbound attachment exceeds {} MB limit\",\n                WECHAT_MEDIA_MAX_BYTES / (1024 * 1024)\n            );\n        }\n\n        match spec.aes_key.as_deref() {\n            Some(aes_key) if !aes_key.is_empty() => {\n                let key = parse_aes_key(aes_key)?;\n                decrypt_aes_ecb(&bytes, &key)\n            }\n            _ => Ok(bytes),\n        }\n    }\n\n    async fn try_build_attachment_content(\n        &self,\n        items: &[serde_json::Value],\n        message_id: &str,","sourceCodeStart":1541,"sourceCodeEnd":1577,"githubUrl":"https://github.com/zeroclaw-labs/zeroclaw/blob/88bb9c8533fc57ed7a03e36ca7c9ed2bf8336dcc/crates/zeroclaw-channels/src/wechat.rs#L1541-L1577","documentation":"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.","triggerScenarios":"Any inbound WeChat attachment whose downloaded byte length exceeds 100 MB — typically large videos or file transfers forwarded to the bot.","commonSituations":"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.","solutions":["Reply to the sender that the file exceeds the bot's 100 MB limit and ask for a link instead","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","Handle the error per-attachment so the rest of the message (text, smaller parts) is still processed"],"exampleFix":"// before (crates/zeroclaw-channels/src/wechat.rs)\nconst WECHAT_MEDIA_MAX_BYTES: u64 = 100 * 1024 * 1024;\n// after (deliberately raise the cap, then rebuild)\nconst WECHAT_MEDIA_MAX_BYTES: u64 = 200 * 1024 * 1024;","handlingStrategy":"validation","validationCode":"// Pre-check the size reported in the inbound message metadata before triggering the download\nconst WECHAT_MEDIA_MAX_BYTES: u64 = 100 * 1024 * 1024;\nif let Some(size) = inbound.attachment_reported_size() {\n    if size as u64 > WECHAT_MEDIA_MAX_BYTES {\n        reply(chat, \"File too large for this bot (max 100 MB). Please share a link.\").await;\n        return Ok(());\n    }\n}","typeGuard":null,"tryCatchPattern":"Catch the 'inbound attachment exceeds' bail per attachment, reply with a size-limit notice, and continue processing the rest of the message.","preventionTips":["Announce the 100 MB inbound limit in channel onboarding text","Pre-check any reported file size from message metadata before downloading","Monitor this error to spot users who routinely send oversized media"],"tags":["wechat","attachment","size-limit","media","validation","inbound"],"backgroundTag":"file-size-limit-exceeded","analyzedSha":"88bb9c8533fc57ed7a03e36ca7c9ed2bf8336dcc","analyzedAt":"2026-08-23T01:07:41.857Z","schemaVersion":2},"datasetVersion":"2026-08-23T08:06:27.607Z"}