anomalyco/sst · error
failed to open zip: %w
Error message
failed to open zip: %w
What it means
`extractZip` opens the .whl with Go's `zip.OpenReader`; any failure to open or parse the zip central directory is wrapped in this error. It is the low-level sibling of the corrupt-wheel problem: the file exists but is not a readable zip.
Source
Thrown at pkg/runtime/python/build.go:353
extractedDir := filepath.Join(outputDir, dirName)
targetDir := filepath.Join(outputDir, baseName)
// Move extracted directory to target
if err := moveExtractedPackage(extractedDir, targetDir, baseName); err != nil {
return fmt.Errorf("failed to move extracted package: %w", err)
}
// Remove the original archive
os.Remove(archiveFile)
return nil
}
// extractZip extracts a zip archive (used for .whl files) to the destination directory.
func extractZip(archiveFile, destDir string) error {
r, err := zip.OpenReader(archiveFile)
if err != nil {
return fmt.Errorf("failed to open zip: %w", err)
}
defer r.Close()
for _, f := range r.File {
// Guard against zip slip
target := filepath.Join(destDir, f.Name)
if !strings.HasPrefix(filepath.Clean(target), filepath.Clean(destDir)+string(os.PathSeparator)) {
return fmt.Errorf("illegal file path in zip: %s", f.Name)
}
if f.FileInfo().IsDir() {
if err := os.MkdirAll(target, 0755); err != nil {
return err
}
continue
}
if err := os.MkdirAll(filepath.Dir(target), 0755); err != nil {View on GitHub (pinned to a0bd20f762)
Solutions
- Delete the invalid .whl and rebuild so pip re-downloads it
- Verify zip integrity: `python -m zipfile -t <file>.whl` or `unzip -t`
- Clear CI/build caches that may hold partially written wheels
- Ensure sufficient disk space and stable network (disable restrictive proxies) during install
Example fix
// before: cached truncated wheel in CI # sst deploy -> failed to open zip: unexpected EOF // after: clear cache then deploy cache.clear() ; sst deploy
Defensive patterns
Strategy: try-catch
Validate before calling
import { readFileSync } from "fs";
const fd = readFileSync(archivePath);
if (!(fd[0] === 0x50 && fd[1] === 0x4b)) throw new Error(`${archivePath} is not a zip (wheel)`); Try / catch
try {
await buildPackage(...);
} catch (e) {
if (String(e).includes("failed to open zip")) {
console.error("Wheel is not a valid zip — force re-download:", e);
}
throw e;
} Prevention
- Clear CI caches of partially written wheels
- Ensure adequate disk space during installs
- Use stable network/proxy settings for pip downloads
- Validate zip magic bytes (PK) before trusting cached wheels
When it happens
Trigger: `processPackageArchive` matched a `.whl` whose bytes are not a zip — 0-byte file, truncated download, or a file with a .whl extension that is actually text/binary of another format.
Common situations: Interrupted or proxied pip downloads; disk-full writes; CI caches restoring partially written artifacts.
Related errors
- failed to extract wheel: %w
- failed to process archive %s: %w
- failed to extract archive: %w
- illegal file path in zip: %s
- failed to create gzip reader: %w
AI-assisted analysis of anomalyco/sst@a0bd20f762 (2026-08-30).
Data as JSON: /api/errors/fb08c7c680bc1555.
Report an issue: GitHub.