{"record":{"id":"fb08c7c680bc1555","repo":"anomalyco/sst","slug":"failed-to-open-zip-w","errorCode":null,"errorMessage":"failed to open zip: %w","messagePattern":"failed to open zip: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/runtime/python/build.go","lineNumber":353,"sourceCode":"\textractedDir := filepath.Join(outputDir, dirName)\n\ttargetDir := filepath.Join(outputDir, baseName)\n\n\t// Move extracted directory to target\n\tif err := moveExtractedPackage(extractedDir, targetDir, baseName); err != nil {\n\t\treturn fmt.Errorf(\"failed to move extracted package: %w\", err)\n\t}\n\n\t// Remove the original archive\n\tos.Remove(archiveFile)\n\n\treturn nil\n}\n\n// extractZip extracts a zip archive (used for .whl files) to the destination directory.\nfunc extractZip(archiveFile, destDir string) error {\n\tr, err := zip.OpenReader(archiveFile)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to open zip: %w\", err)\n\t}\n\tdefer r.Close()\n\n\tfor _, f := range r.File {\n\t\t// Guard against zip slip\n\t\ttarget := filepath.Join(destDir, f.Name)\n\t\tif !strings.HasPrefix(filepath.Clean(target), filepath.Clean(destDir)+string(os.PathSeparator)) {\n\t\t\treturn fmt.Errorf(\"illegal file path in zip: %s\", f.Name)\n\t\t}\n\n\t\tif f.FileInfo().IsDir() {\n\t\t\tif err := os.MkdirAll(target, 0755); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tcontinue\n\t\t}\n\n\t\tif err := os.MkdirAll(filepath.Dir(target), 0755); err != nil {","sourceCodeStart":335,"sourceCodeEnd":371,"githubUrl":"https://github.com/anomalyco/sst/blob/a0bd20f762883e72a35caccb4896c42ce5b3f707/pkg/runtime/python/build.go#L335-L371","documentation":"`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.","triggerScenarios":"`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.","commonSituations":"Interrupted or proxied pip downloads; disk-full writes; CI caches restoring partially written artifacts.","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"],"exampleFix":"// before: cached truncated wheel in CI\n# sst deploy -> failed to open zip: unexpected EOF\n// after: clear cache then deploy\ncache.clear() ; sst deploy","handlingStrategy":"try-catch","validationCode":"import { readFileSync } from \"fs\";\nconst fd = readFileSync(archivePath);\nif (!(fd[0] === 0x50 && fd[1] === 0x4b)) throw new Error(`${archivePath} is not a zip (wheel)`);","typeGuard":null,"tryCatchPattern":"try {\n  await buildPackage(...);\n} catch (e) {\n  if (String(e).includes(\"failed to open zip\")) {\n    console.error(\"Wheel is not a valid zip — force re-download:\", e);\n  }\n  throw e;\n}","preventionTips":["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"],"tags":["python","wheel","zip","corrupt-file"],"backgroundTag":"archive-extraction-failed","analyzedSha":"a0bd20f762883e72a35caccb4896c42ce5b3f707","analyzedAt":"2026-08-30T11:26:00.383Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}