BigPizzaV3/CodexPlusPlus · error · anyhow::Error

zip entry has empty path

Error message

zip entry has empty path

What it means

safe_zip_path also rejects zip entries whose sanitized relative path ends up empty — entries with no Normal components at all. This prevents creating a zero-length or directoryless path during extraction of malformed archives.

Solutions

  1. Re-download the marketplace zip from the official source
  2. Inspect with `unzip -l` and strip or ignore entries with empty/'.' names, repacking if you control the archive
  3. Use a different zip tool to regenerate the archive so it omits pseudo root entries

Example fix

# before
unzip -l bad.zip  →  entry name: ''
# after (repack)
zip -r fixed.zip plugins/   # only real paths, no '.' entries
Defensive patterns

Strategy: validation

Validate before calling

if name.is_empty() || Path::new(name).components().next().is_none() {
    skip_entry(name);
}

Try / catch

match safe_zip_path(name) {
    Ok(rel) => extract(rel),
    Err(e) if e.to_string().contains("empty path") => continue, // skip pseudo entries
    Err(e) => return Err(e),
}

Prevention

When it happens

Trigger: extract_zip_exact encounters an entry whose name is empty, '.', './', or consists solely of CurDir components, so `relative` stays empty and the check `relative.as_os_str().is_empty()` fires.

Common situations: Archives that store the root directory itself as a '.' entry; zips produced by buggy tooling; truncated or corrupted archive central directories yielding blank entry names.

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 BigPizzaV3/CodexPlusPlus@b1ed92e5e4 (2026-09-19). Data as JSON: /api/errors/ec776213979574fa. Report an issue: GitHub.

Appendix: source

Thrown at crates/codex-plus-core/src/plugin_marketplace.rs:482

            .with_context(|| format!("failed to read zip entry {}", file.name()))?;
        std::fs::write(&output_path, contents)
            .with_context(|| format!("failed to write {}", output_path.display()))?;
    }
    Ok(())
}

fn safe_zip_path(name: &str) -> anyhow::Result<PathBuf> {
    let path = Path::new(name);
    let mut relative = PathBuf::new();
    for component in path.components() {
        match component {
            Component::Normal(value) => relative.push(value),
            Component::CurDir => {}
            _ => anyhow::bail!("zip entry escapes destination: {name}"),
        }
    }
    if relative.as_os_str().is_empty() {
        anyhow::bail!("zip entry has empty path");
    }
    Ok(relative)
}

pub(crate) fn zip_entry_relative_path(name: &str) -> Option<PathBuf> {
    let path = Path::new(name);
    let mut components = path.components();
    match components.next()? {
        Component::Normal(_) => {}
        _ => return None,
    }
    let mut relative = PathBuf::new();
    for component in components {
        match component {
            Component::Normal(value) => relative.push(value),
            Component::CurDir => {}
            _ => return None,
        }

View on GitHub (pinned to b1ed92e5e4)