zeroclaw-labs/zeroclaw · error · anyhow::Error
inbound attachment exceeds {} MB limit
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.
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)
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
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
- 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
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.
Related errors
- media aes_key must decode to 16 raw bytes or 32 hex chars, g
- attachment Content-Length ({len} bytes) exceeds {} MB limit
- attachment exceeds {} MB limit
- WeCom max_file_size_bytes is zero
- WeCom attachment download failed: kind={} msg_id={} url_targ
AI-assisted analysis of zeroclaw-labs/zeroclaw@88bb9c8533 (2026-08-23).
Data as JSON: /api/errors/502cea474e2983b7.
Report an issue: GitHub.