{"record":{"id":"72f5302d05ea382b","repo":"astrid-runtime/astrid","slug":"wit-file-exceeds-1mb-size-limit","errorCode":null,"errorMessage":"WIT file {} exceeds 1MB size limit ({})","messagePattern":"WIT file (.+?) exceeds 1MB size limit \\((.+?)\\)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/astrid-capsule-install/src/wit.rs","lineNumber":106,"sourceCode":"        let entry = entry?;\n        let path = entry.path();\n        let file_type = entry.file_type()?;\n\n        if file_type.is_dir() {\n            content_address_wit_recursive(wit_root, &path, wit_store, store_ready, hashes)?;\n            continue;\n        }\n\n        if !file_type.is_file() || path.extension().and_then(|e| e.to_str()) != Some(\"wit\") {\n            continue;\n        }\n\n        // 1 MB cap — keeps a hostile or accidental gigabyte .wit from\n        // either blowing memory or filling the content store.\n        let metadata = std::fs::metadata(&path)\n            .with_context(|| format!(\"failed to stat {}\", path.display()))?;\n        if metadata.len() > 1024 * 1024 {\n            bail!(\n                \"WIT file {} exceeds 1MB size limit ({})\",\n                path.display(),\n                metadata.len(),\n            );\n        }\n\n        let rel_path = path\n            .strip_prefix(wit_root)\n            .with_context(|| {\n                format!(\n                    \"WIT path {} not under wit root {}\",\n                    path.display(),\n                    wit_root.display()\n                )\n            })?\n            .to_string_lossy()\n            .into_owned();\n","sourceCodeStart":88,"sourceCodeEnd":124,"githubUrl":"https://github.com/astrid-runtime/astrid/blob/affd8760f44190dbdfbec23403f4c4b642c33112/crates/astrid-capsule-install/src/wit.rs#L88-L124","documentation":"When computing the content address of a WIT world, the tooling recursively hashes WIT files but refuses any single file larger than 1 MiB (1024*1024 bytes). The cap prevents a hostile or accidentally huge .wit file from exhausting memory or filling the content store. The error includes the file path and its actual byte length.","triggerScenarios":"content_address_wit (via content_address_wit_recursive) stats a .wit file whose std::fs::metadata len exceeds 1 MiB.","commonSituations":"Generated WIT files that concatenated many worlds or inlined large data; a binary or log accidentally committed with a .wit extension; vendoring tooling that copied an oversized file into the wit directory.","solutions":["Trim or split the oversized .wit file so each file is under 1 MiB.","Remove non-WIT or generated junk files with a .wit extension from the WIT directory.","If the large file is legitimate, request a raise of the 1 MiB cap in a patched build."],"exampleFix":"// before: oversized generated file in wit/\n$ ls -l wit/\n-rw-r--r-- 1 user user 2400000 all-worlds.wit   # > 1MB → bail\n\n// after: split or remove\n$ rm wit/all-worlds.wit\n$ split_worlds.py --out wit/   # each file < 1MB","handlingStrategy":"validation","validationCode":"for entry in walkdir::WalkDir::new(wit_dir) {\n    let p = entry.path();\n    if p.extension().map_or(false, |e| e == \"wit\") {\n        let len = std::fs::metadata(p)?.len();\n        if len > 1024 * 1024 {\n            eprintln!(\"{} is {} bytes; trim below 1MiB\", p.display(), len);\n        }\n    }\n}","typeGuard":"fn wit_within_limit(path: &std::path::Path) -> bool {\n    std::fs::metadata(path).map(|m| m.len() <= 1024 * 1024).unwrap_or(false)\n}","tryCatchPattern":"match content_address_wit(&path) {\n    Ok(addr) => { /* ... */ }\n    Err(e) if e.to_string().contains(\"exceeds 1MB size limit\") => {\n        eprintln!(\"split or trim the oversized .wit file\");\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Add a CI check asserting every *.wit file is < 1 MiB.","Never give generated dumps or binaries a .wit extension.","Review generation scripts that could concatenate worlds into one file.","Split large worlds across multiple .wit files by design."],"tags":["wit","file-size","limit-exceeded","content-addressing"],"backgroundTag":"file-size-limit-exceeded","analyzedSha":"affd8760f44190dbdfbec23403f4c4b642c33112","analyzedAt":"2026-09-09T21:28:12.402Z","contentChangedAt":"2026-09-09T21:28:12.402Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}