{"record":{"id":"ec776213979574fa","repo":"BigPizzaV3/CodexPlusPlus","slug":"zip-entry-has-empty-path","errorCode":null,"errorMessage":"zip entry has empty path","messagePattern":"zip entry has empty path","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/codex-plus-core/src/plugin_marketplace.rs","lineNumber":482,"sourceCode":"            .with_context(|| format!(\"failed to read zip entry {}\", file.name()))?;\n        std::fs::write(&output_path, contents)\n            .with_context(|| format!(\"failed to write {}\", output_path.display()))?;\n    }\n    Ok(())\n}\n\nfn safe_zip_path(name: &str) -> anyhow::Result<PathBuf> {\n    let path = Path::new(name);\n    let mut relative = PathBuf::new();\n    for component in path.components() {\n        match component {\n            Component::Normal(value) => relative.push(value),\n            Component::CurDir => {}\n            _ => anyhow::bail!(\"zip entry escapes destination: {name}\"),\n        }\n    }\n    if relative.as_os_str().is_empty() {\n        anyhow::bail!(\"zip entry has empty path\");\n    }\n    Ok(relative)\n}\n\npub(crate) fn zip_entry_relative_path(name: &str) -> Option<PathBuf> {\n    let path = Path::new(name);\n    let mut components = path.components();\n    match components.next()? {\n        Component::Normal(_) => {}\n        _ => return None,\n    }\n    let mut relative = PathBuf::new();\n    for component in components {\n        match component {\n            Component::Normal(value) => relative.push(value),\n            Component::CurDir => {}\n            _ => return None,\n        }","sourceCodeStart":464,"sourceCodeEnd":500,"githubUrl":"https://github.com/BigPizzaV3/CodexPlusPlus/blob/b1ed92e5e4a2d74095d4b8db5af43cef7acba9c6/crates/codex-plus-core/src/plugin_marketplace.rs#L464-L500","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Re-download the marketplace zip from the official source","Inspect with `unzip -l` and strip or ignore entries with empty/'.' names, repacking if you control the archive","Use a different zip tool to regenerate the archive so it omits pseudo root entries"],"exampleFix":"# before\nunzip -l bad.zip  →  entry name: ''\n# after (repack)\nzip -r fixed.zip plugins/   # only real paths, no '.' entries","handlingStrategy":"validation","validationCode":"if name.is_empty() || Path::new(name).components().next().is_none() {\n    skip_entry(name);\n}","typeGuard":null,"tryCatchPattern":"match safe_zip_path(name) {\n    Ok(rel) => extract(rel),\n    Err(e) if e.to_string().contains(\"empty path\") => continue, // skip pseudo entries\n    Err(e) => return Err(e),\n}","preventionTips":["Repack archives with standard tooling that omits '.' root entries","Skip rather than fail on directory-only pseudo entries where safe","Validate zip integrity after download"],"tags":["zip","validation","malformed-archive"],"backgroundTag":"invalid-argument-format","analyzedSha":"b1ed92e5e4a2d74095d4b8db5af43cef7acba9c6","analyzedAt":"2026-09-19T23:35:21.129Z","contentChangedAt":"2026-09-19T23:35:21.129Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}