BoundaryML/baml · error · FetchError

zip archive error: {0}

Error message

zip archive error: {0}

What it means

FetchError::Zip wraps a zip::result::ZipError raised while reading or extracting a downloaded BAML release archive. The library converts the underlying zip crate error via #[from], so any corrupt, truncated, or unsupported archive surfaces as "zip archive error: {0}". It indicates the fetched artifact could not be decompressed, not that the download itself failed.

Source

Thrown at baml_language/crates/baml_release/src/lib.rs:103

    #[error("manifest 404 for version {version} (not released yet?)")]
    ManifestNotFound { version: String },
    #[error("manifest schema {got} not supported (max {max}); run `baml self-update`")]
    ManifestSchemaTooNew { got: u32, max: u32 },
    #[error("target {target} not built for version {version}")]
    TargetNotInManifest { target: String, version: String },
    #[error("sha256 mismatch for {url}: expected {expected}, got {got}")]
    ChecksumMismatch {
        url: String,
        expected: String,
        got: String,
    },
    #[error("archive missing expected binary {name}")]
    BinaryNotInArchive { name: String },
    #[error("archive contains unsafe path {path}")]
    UnsafeArchivePath { path: String },
    #[error("disk error: {0}")]
    Io(#[from] std::io::Error),
    #[error("zip archive error: {0}")]
    Zip(#[from] zip::result::ZipError),
}

#[derive(Debug, Clone)]
pub struct Fetcher {
    pub spec: ReleaseSpec,
    pub product: Product,
    pub manifest_base_url: String,
    pub release_repo: String,
    artifact: Option<Artifact>,
}

impl Fetcher {
    pub fn default_for(spec: ReleaseSpec, product: Product) -> Self {
        Self {
            spec,
            product,
            manifest_base_url: manifest_base_url(),

View on GitHub (pinned to bd85ce9dee)

Solutions

  1. Delete the cached/partial archive and re-download the release to rule out truncation.
  2. Verify the URL returned a real zip asset (check for proxy/HTML error pages in the file header).
  3. Run `file`/unzip manually on the archive to confirm integrity.
  4. Check the archive's compression method is one supported by the bundled zip crate version.

Example fix

// before: blindly extract whatever was downloaded
extract(&archive_bytes, dest)?;
// after: sanity-check the archive before extraction
if !archive_bytes.starts_with(b"PK") {
    return Err(FetchError::Io(std::io::Error::new(
        std::io::ErrorKind::InvalidData,
        "downloaded artifact is not a zip archive; re-download",
    )));
}
extract(&archive_bytes, dest)?;
Defensive patterns

Strategy: try-catch

Validate before calling

if bytes.len() < 4 || !bytes.starts_with(b"PK") {
    return Err("downloaded artifact is not a zip archive".into());
}

Try / catch

match fetch_and_extract() {
    Err(FetchError::Zip(e)) => { re_download_and_retry(); }
    Err(other) => return Err(other),
    Ok(v) => v,
}

Prevention

When it happens

Trigger: Calling download/extract paths in baml_release (e.g. the Fetcher flow) on bytes that are not a valid ZIP: truncated download, HTML error page saved as archive, unsupported compression method, or password-protected entry.

Common situations: Corporate proxy returning an error page instead of the release asset; interrupted download leaving a partial file; CDN corruption; manually edited or re-saved archive; very old zip features unsupported by the zip crate version.

Understand the failure class

Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.

Related errors


AI-assisted analysis of BoundaryML/baml@bd85ce9dee (2026-09-12). Data as JSON: /api/errors/2983d2fc2563fd74. Report an issue: GitHub.