astrid-runtime/astrid · error

local capsule source

Error message

local capsule source {source:?} is {} bytes, exceeding the {MAX_MEMBER_BYTES}-byte member limit

What it means

resolve_local_capsule_archive enforces MAX_MEMBER_BYTES on every local capsule member to bound memory/disk use. If the file's size exceeds the limit, the source is rejected with a message reporting its actual byte size and the configured cap.

Solutions

  1. Shrink or rebuild the capsule so it fits under the MAX_MEMBER_BYTES limit
  2. Split the capsule into smaller members or move heavy assets to the registry
  3. Strip debug symbols/unneeded payloads from the archive before sealing

Example fix

// before
source = "artifacts/huge-bundle.capsule"  // 2 GB
// after
source = "artifacts/core-min.capsule"     // rebuilt under the size limit
Defensive patterns

Strategy: validation

Validate before calling

let md = std::fs::metadata(capsule_path)?;
if md.len() > MAX_MEMBER_BYTES {
    anyhow::bail!("capsule source exceeds the {}-byte member limit", MAX_MEMBER_BYTES);
}

Prevention

When it happens

Trigger: Referencing an unusually large capsule archive (> MAX_MEMBER_BYTES) as a local member in Distro.toml.

Common situations: Accidentally vendoring a huge artifact (debug builds, bundled binaries) as a capsule; a build script that never pruned the archive.

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/2cf1d28fa18b77ce. Report an issue: GitHub.

Appendix: source

Thrown at crates/astrid-cli/src/commands/distro/local_source.rs:86

        bail!("local capsule source {source:?} escapes the authenticated Distro.toml directory");
    }

    let canonical_root = root
        .canonicalize()
        .with_context(|| format!("failed to resolve Distro.toml directory {}", root.display()))?;
    let canonical_path = candidate
        .canonicalize()
        .with_context(|| format!("failed to resolve local capsule source {source:?}"))?;
    if !canonical_path.starts_with(&canonical_root) {
        bail!("local capsule source {source:?} escapes the authenticated Distro.toml directory");
    }
    let metadata = std::fs::metadata(&canonical_path)
        .with_context(|| format!("failed to stat local capsule source {source:?}"))?;
    if !metadata.is_file() {
        bail!("local capsule source {source:?} is not a regular file");
    }
    if metadata.len() > MAX_MEMBER_BYTES {
        bail!(
            "local capsule source {source:?} is {} bytes, exceeding the \
             {MAX_MEMBER_BYTES}-byte member limit",
            metadata.len()
        );
    }

    Ok(Some(canonical_path))
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn resolves_relative_member_from_manifest_parent() {
        let dir = tempfile::tempdir().unwrap();
        let manifest = dir.path().join("Distro.toml");
        std::fs::create_dir_all(dir.path().join("capsules")).unwrap();

View on GitHub (pinned to affd8760f4)