astrid-runtime/astrid · error

WIT file exceeds 1MB size limit ( )

Error message

WIT file {} exceeds 1MB size limit ({})

What it means

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.

Solutions

  1. Trim or split the oversized .wit file so each file is under 1 MiB.
  2. Remove non-WIT or generated junk files with a .wit extension from the WIT directory.
  3. If the large file is legitimate, request a raise of the 1 MiB cap in a patched build.

Example fix

// before: oversized generated file in wit/
$ ls -l wit/
-rw-r--r-- 1 user user 2400000 all-worlds.wit   # > 1MB → bail

// after: split or remove
$ rm wit/all-worlds.wit
$ split_worlds.py --out wit/   # each file < 1MB
Defensive patterns

Strategy: validation

Validate before calling

for entry in walkdir::WalkDir::new(wit_dir) {
    let p = entry.path();
    if p.extension().map_or(false, |e| e == "wit") {
        let len = std::fs::metadata(p)?.len();
        if len > 1024 * 1024 {
            eprintln!("{} is {} bytes; trim below 1MiB", p.display(), len);
        }
    }
}

Type guard

fn wit_within_limit(path: &std::path::Path) -> bool {
    std::fs::metadata(path).map(|m| m.len() <= 1024 * 1024).unwrap_or(false)
}

Try / catch

match content_address_wit(&path) {
    Ok(addr) => { /* ... */ }
    Err(e) if e.to_string().contains("exceeds 1MB size limit") => {
        eprintln!("split or trim the oversized .wit file");
    }
    Err(e) => return Err(e),
}

Prevention

When it happens

Trigger: content_address_wit (via content_address_wit_recursive) stats a .wit file whose std::fs::metadata len exceeds 1 MiB.

Common situations: 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.

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 astrid-runtime/astrid@affd8760f4 (2026-09-09). Data as JSON: /api/errors/72f5302d05ea382b. Report an issue: GitHub.

Appendix: source

Thrown at crates/astrid-capsule-install/src/wit.rs:106

        let entry = entry?;
        let path = entry.path();
        let file_type = entry.file_type()?;

        if file_type.is_dir() {
            content_address_wit_recursive(wit_root, &path, wit_store, store_ready, hashes)?;
            continue;
        }

        if !file_type.is_file() || path.extension().and_then(|e| e.to_str()) != Some("wit") {
            continue;
        }

        // 1 MB cap — keeps a hostile or accidental gigabyte .wit from
        // either blowing memory or filling the content store.
        let metadata = std::fs::metadata(&path)
            .with_context(|| format!("failed to stat {}", path.display()))?;
        if metadata.len() > 1024 * 1024 {
            bail!(
                "WIT file {} exceeds 1MB size limit ({})",
                path.display(),
                metadata.len(),
            );
        }

        let rel_path = path
            .strip_prefix(wit_root)
            .with_context(|| {
                format!(
                    "WIT path {} not under wit root {}",
                    path.display(),
                    wit_root.display()
                )
            })?
            .to_string_lossy()
            .into_owned();

View on GitHub (pinned to affd8760f4)