astrid-runtime/astrid · error

exceeds size limit

Error message

{name} exceeds size limit

What it means

fetch_url_bytes streams the HTTP response in chunks and enforces a hard cap (1 MiB for signed source members) after every chunk, throwing this error as soon as the accumulated bytes exceed `limit`. This bounds memory usage so a compromised or misconfigured distro mirror cannot make the CLI buffer an unbounded body.

Solutions

  1. Check what the URL actually returns — an oversized HTML error page from a misconfigured mirror is the usual culprit; fix the mirror URL
  2. If the signed manifest legitimately exceeds 1 MiB, serve/split it differently or host it locally and use the local-file path in fetch_signed_member, which has no size limit
  3. Investigate proxies/intermediaries that inflate response bodies

Example fix

// before: oversized body from wrong URL
let url = "https://example.com/"; // returns big HTML page
// after
let url = "https://mirror.example.com/distro/Distro.lock";
Defensive patterns

Strategy: validation

Validate before calling

// HEAD the URL and check Content-Length before a full fetch
let len = client.head(url).send().await?
    .headers().get(reqwest::header::CONTENT_LENGTH)
    .and_then(|v| v.to_str().ok())
    .and_then(|v| v.parse::<usize>().ok());
if let Some(n) = len { anyhow::ensure!(n <= 1024*1024, "{name} would exceed 1 MiB"); }

Try / catch

match fetch_url_bytes(url, name, LIMIT).await {
    Err(e) if e.to_string().ends_with("exceeds size limit") => {
        eprintln!("{name} is larger than the 1 MiB cap; check the URL returns the real file, not an error page");
    }
    r => r?,
}

Prevention

When it happens

Trigger: Any fetch through fetch_url_bytes (fetch_manifest_bytes or fetch_signed_member) where the server returns a body larger than the 1 MiB limit — e.g. fetching Distro.toml, Distro.lock, or the .sig file whose size exceeds 1048576 bytes.

Common situations: A mirror serving an HTML error page/redirect loop with a large body, a proxy injecting content, or a legitimate distro whose manifest/signature grew past 1 MiB (very large capsule sets).

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/45ffc6c10f4c50a2. Report an issue: GitHub.

Appendix: source

Thrown at crates/astrid-cli/src/commands/init_signed_source.rs:281

        .user_agent("astrid-cli")
        .timeout(std::time::Duration::from_secs(30))
        .build()?;
    let response = client
        .get(url)
        .send()
        .await
        .with_context(|| format!("failed to fetch {name}"))?;
    if !response.status().is_success() {
        bail!(
            "failed to fetch {name} from {url} (HTTP {})",
            response.status()
        );
    }
    let mut bytes = Vec::new();
    let mut response = response;
    while let Some(chunk) = response.chunk().await? {
        bytes.extend_from_slice(&chunk);
        anyhow::ensure!(bytes.len() <= limit, "{name} exceeds size limit");
    }
    Ok(bytes)
}

/// Bind exact TOML bytes into the signed lock, then verify that lock.
fn verify_signed_manifest(
    home: &AstridHome,
    manifest: &DistroManifest,
    manifest_hash: &str,
    lock: &DistroLock,
    sig_hex: &str,
    accept_new_key: bool,
) -> anyhow::Result<HashMap<String, String>> {
    if lock.manifest_hash.as_deref() != Some(manifest_hash) {
        bail!(
            "signed Distro.toml does not match Distro.lock manifest_hash; refusing to resolve members"
        );
    }

View on GitHub (pinned to affd8760f4)