{"record":{"id":"c83fa5ddec283c0d","repo":"anomalyco/sst","slug":"failed-to-extract-archive-w","errorCode":null,"errorMessage":"failed to extract archive: %w","messagePattern":"failed to extract archive: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/runtime/python/build.go","lineNumber":323,"sourceCode":"\n\treturn nil\n}\n\n// processPackageArchive extracts and cleans up a single package archive\nfunc processPackageArchive(archiveFile, outputDir string) error {\n\tif strings.HasSuffix(archiveFile, \".whl\") {\n\t\tif err := extractZip(archiveFile, outputDir); err != nil {\n\t\t\treturn fmt.Errorf(\"failed to extract wheel: %w\", err)\n\t\t}\n\n\t\tos.Remove(archiveFile)\n\n\t\treturn nil\n\t}\n\n\t// Extract tar.gz\n\tif err := extractTarGz(archiveFile, outputDir); err != nil {\n\t\treturn fmt.Errorf(\"failed to extract archive: %w\", err)\n\t}\n\n\t// Get the directory name without version number\n\tarchiveBaseName := filepath.Base(archiveFile)\n\tdirName := strings.TrimSuffix(archiveBaseName, \".tar.gz\")\n\tlastHyphen := strings.LastIndex(dirName, \"-\")\n\tif lastHyphen == -1 {\n\t\treturn fmt.Errorf(\"invalid archive name format: %s\", archiveBaseName)\n\t}\n\n\tbaseName := dirName[:lastHyphen]\n\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}","sourceCodeStart":305,"sourceCodeEnd":341,"githubUrl":"https://github.com/anomalyco/sst/blob/a0bd20f762883e72a35caccb4896c42ce5b3f707/pkg/runtime/python/build.go#L305-L341","documentation":"When the matched archive is a `.tar.gz` (sdist), `processPackageArchive` extracts it with `extractTarGz`. This error wraps failure of that extraction — invalid gzip data, corrupt tar stream, or filesystem errors during unpacking.","triggerScenarios":"Glob matched a `*.tar.gz` file that is not a valid gzip/tar (partial download, wrong file), or the output directory is not writable during extraction.","commonSituations":"Proxied/network errors saving HTML as .tar.gz; disk space exhaustion mid-extract; corrupted sdist from a private PyPI mirror.","solutions":["Delete the corrupt .tar.gz from the build output and rebuild","Validate the file: `tar -tzf <file>.tar.gz` should list entries without errors","Check disk space and write permissions on outputDir","Bypass unreliable mirrors by pointing pip at official PyPI"],"exampleFix":"// before: private mirror serving corrupt sdists\n// after: pin to official PyPI\npip config set global.index-url https://pypi.org/simple","handlingStrategy":"validation","validationCode":"import { execSync } from \"child_process\";\nexecSync(`tar -tzf ${archivePath}`, { stdio: \"ignore\" }); // throws if corrupt","typeGuard":null,"tryCatchPattern":"try {\n  await buildPackage(...);\n} catch (e) {\n  if (String(e).includes(\"failed to extract archive\")) {\n    console.error(\"Invalid tar.gz sdist — rebuild from a clean output dir:\", e);\n  }\n  throw e;\n}","preventionTips":["Point pip at the official PyPI index instead of flaky mirrors","Check disk space before building","Re-download sdists after any network interruption","Verify sdists with `tar -tzf` before relying on them"],"tags":["python","tar","extraction","corrupt-file"],"backgroundTag":"archive-extraction-failed","analyzedSha":"a0bd20f762883e72a35caccb4896c42ce5b3f707","analyzedAt":"2026-08-30T11:26:00.383Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}