{"record":{"id":"12cc58bb59184bc0","repo":"tonhowtf/omniget","slug":"zip-invalido","errorCode":null,"errorMessage":"zip invalido: {}","messagePattern":"zip invalido: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src-tauri/omniget-core/src/core/spicetify.rs","lineNumber":468,"sourceCode":"        }\n    } else if cfg!(target_os = \"macos\") {\n        if cfg!(target_arch = \"aarch64\") {\n            \"darwin-arm64.tar.gz\"\n        } else {\n            \"darwin-amd64.tar.gz\"\n        }\n    } else if cfg!(target_arch = \"x86_64\") {\n        \"linux-amd64.tar.gz\"\n    } else {\n        return Err(anyhow!(\n            \"o Spicetify nao publica binario para Linux nesta arquitetura; instale pelo gerenciador de pacotes\"\n        ));\n    })\n}\n\nfn unpack_zip(data: &[u8], dest: &Path) -> anyhow::Result<()> {\n    let mut archive = zip::ZipArchive::new(std::io::Cursor::new(data))\n        .map_err(|e| anyhow!(\"zip invalido: {}\", e))?;\n    for i in 0..archive.len() {\n        let mut file = archive.by_index(i)?;\n        let Some(rel) = file.enclosed_name() else {\n            continue;\n        };\n        let out = dest.join(rel);\n        if file.is_dir() {\n            std::fs::create_dir_all(&out)?;\n            continue;\n        }\n        if let Some(parent) = out.parent() {\n            std::fs::create_dir_all(parent)?;\n        }\n        let mut w = std::fs::File::create(&out)?;\n        std::io::copy(&mut file, &mut w)?;\n    }\n    Ok(())\n}","sourceCodeStart":450,"sourceCodeEnd":486,"githubUrl":"https://github.com/tonhowtf/omniget/blob/8600b91f4246848bac346874daa9e61c1fc5677a/src-tauri/omniget-core/src/core/spicetify.rs#L450-L486","documentation":"`unpack_zip` extracts a downloaded ZIP (Windows Spicetify CLI) using the `zip` crate. If the bytes cannot be opened as a ZIP archive at all — corrupt download, HTML error page saved instead, or truncated file — it fails with this error wrapping the underlying zip error.","triggerScenarios":"`unpack_zip(data, dest)` where `ZipArchive::new` fails: response bytes are an error page/proxy HTML instead of a ZIP, download truncated, or file stored corrupted on disk.","commonSituations":"Captive portal/proxy injecting HTML into the download; partial download from an interrupted connection; serving the wrong file due to a mis-templated URL.","solutions":["Delete the downloaded file and re-download (preferably with the digest verification intact)","Check the first bytes of the data — `PK\\x03\\x04` means a real ZIP; HTML/`<!DOCTYPE` means a proxy or error page was captured","Bypass any corporate proxy/captive portal and retry the download","Confirm the asset URL points to the actual binary asset, not a redirect/error page"],"exampleFix":"// before\nlet data = std::fs::read(&cached_path)?;\nunpack_zip(&data, &dest)?;\n// after\nlet data = std::fs::read(&cached_path)?;\nif !data.starts_with(b\"PK\\x03\\x04\") {\n    std::fs::remove_file(&cached_path)?; // clear corrupt cache\n    let data = download_verified(&client, &asset).await?;\n}\nunpack_zip(&data, &dest)?;","handlingStrategy":"validation","validationCode":"fn looks_like_zip(data: &[u8]) -> bool { data.starts_with(b\"PK\\x03\\x04\") }\n// call before unpack_zip:\nif !looks_like_zip(&data) { re_download().await?; }","typeGuard":"fn is_zip(data: &[u8]) -> bool { data.len() > 4 && data.starts_with(b\"PK\\x03\\x04\") }","tryCatchPattern":"match unpack_zip(&data, &dest) {\n    Err(e) if e.to_string().contains(\"zip invalido\") => {\n        let fresh = download_verified(&client, &asset).await?;\n        unpack_zip(&fresh, &dest)\n    }\n    other => other,\n}","preventionTips":["Verify the download digest before caching/unpacking","Check the ZIP magic bytes before extraction and re-download on mismatch","Avoid proxies/captive portals during downloads; detect HTML responses early","Delete stale cached archives before retrying"],"tags":["archive","zip","download-corruption"],"backgroundTag":"invalid-argument-format","analyzedSha":"8600b91f4246848bac346874daa9e61c1fc5677a","analyzedAt":"2026-09-12T14:29:19.317Z","contentChangedAt":"2026-09-12T14:29:19.317Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}