{"record":{"id":"2dcdee60a37852c7","repo":"warpdotdev/warp","slug":"file-is-too-large-mb-maximum-size-is-10mb","errorCode":null,"errorMessage":"File is too large ({}MB). Maximum size is 10MB.","messagePattern":"File is too large \\((.+?)MB\\)\\. Maximum size is 10MB\\.","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"app/src/ai/agent_sdk/driver/attachments.rs","lineNumber":305,"sourceCode":"        )\n    })?;\n\n    // Detect MIME type from file data using infer crate, fall back to file extension\n    let mime_type = if file_bytes.len() >= MIN_IMAGE_HEADER_SIZE {\n        infer::get(&file_bytes).map(|kind| kind.mime_type().to_string())\n    } else {\n        None\n    };\n\n    // If infer couldn't detect, fall back to file extension\n    let mime_type = mime_type.unwrap_or_else(|| {\n        from_path(attachment_path)\n            .first_or_octet_stream()\n            .to_string()\n    });\n\n    if file_bytes.len() > MAX_ATTACHMENT_SIZE_BYTES {\n        return Err(anyhow::anyhow!(\n            \"File is too large ({}MB). Maximum size is 10MB.\",\n            file_bytes.len() / (1024 * 1024)\n        ));\n    }\n\n    let base64_data = general_purpose::STANDARD.encode(&file_bytes);\n\n    let file_name = attachment_path\n        .file_name()\n        .and_then(|n| n.to_str())\n        .map(|s| s.to_string())\n        .unwrap_or_else(|| format!(\"task_attachment_{index}\"));\n\n    Ok(AttachmentInput {\n        file_name,\n        mime_type,\n        data: base64_data,\n    })","sourceCodeStart":287,"sourceCodeEnd":323,"githubUrl":"https://github.com/warpdotdev/warp/blob/e72fd7aacbbb2236d9b3be2aad7e7178fe94b4bc/app/src/ai/agent_sdk/driver/attachments.rs#L287-L323","documentation":"Thrown by process_attachment when the fully-read file exceeds MAX_ATTACHMENT_SIZE_BYTES (10 * 1024 * 1024, app/src/ai/attachment_utils.rs:7). All attachment types share this single limit; the reported size is integer-divided by 1MB, so a 10.5MB file shows as 10MB.","triggerScenarios":"Calling process_attachment with a file whose byte length exceeds 10,485,760 — e.g. screenshots from retina displays, log bundles, datasets, or videos passed as agent task attachments. The check happens after the full read, right before base64 encoding.","commonSituations":"Large PNGs/exported PDFs exceeding 10MB; log archives zipped for debugging; users assuming images have a higher limit than other files (they do not — one shared limit); note the truncating integer division makes a 10.9MB file confusingly print '10MB' as if it were at the limit.","solutions":["Compress or split the file to under 10MB (re-encode the screenshot, gzip logs, crop the export).","For text content, paste an excerpt inline in the task instead of attaching the whole file.","If a larger limit is genuinely needed, ask maintainers to raise MAX_ATTACHMENT_SIZE_BYTES — server-side upload caps must agree."],"exampleFix":"// before (CLI)\nwarp agent run --attach build/logs-full.txt\n\n// after\ngzip -9 build/logs-full.txt   # then attach the .gz if < 10MB, or:\nhead -c 10485760 build/logs-full.txt > build/logs-excerpt.txt","handlingStrategy":"validation","validationCode":"const MAX: u64 = 10 * 1024 * 1024;\nlet len = std::fs::metadata(&path)?.len();\nanyhow::ensure!(len <= MAX, \"attachment is {} bytes; limit is {}\", len, MAX);","typeGuard":"fn within_attachment_limit(p: &std::path::Path) -> bool {\n    std::fs::metadata(p).map(|m| m.len() <= 10 * 1024 * 1024).unwrap_or(false)\n}","tryCatchPattern":"if let Err(err) = process_attachment(&path, index) {\n    if err.to_string().contains(\"File is too large\") {\n        // compress/split then retry once with the smaller artifact\n    } else { return Err(err); }\n}","preventionTips":["Check file size with fs::metadata before attaching — cheaper than a full read that then fails.","Remember the 10MB limit is shared by ALL attachment types, including images.","Compress screenshots (PNG → optimized) and gzip logs before attaching."],"tags":["attachments","size-limit","validation","rust"],"backgroundTag":null,"analyzedSha":"e72fd7aacbbb2236d9b3be2aad7e7178fe94b4bc","analyzedAt":"2026-08-16T08:27:25.381Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}