{"record":{"id":"f6a7f8c2d50be7ea","repo":"hashicorp/packer","slug":"extract-file-w","errorCode":null,"errorMessage":"extract file: %w","messagePattern":"extract file: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packer/plugin-getter/plugins.go","lineNumber":874,"sourceCode":"\t\t\t\t\t\tif f.Name != expectedBinaryFilename {\n\t\t\t\t\t\t\tcontinue\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcopyFrom, err = f.Open()\n\t\t\t\t\t\tif err != nil {\n\t\t\t\t\t\t\terrs = multierror.Append(errs, fmt.Errorf(\"failed to open temp file: %w\", err))\n\t\t\t\t\t\t\treturn nil, errs\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}\n\t\t\t\t\tif copyFrom == nil {\n\t\t\t\t\t\terr := fmt.Errorf(\"could not find a %q file in zipfile\", expectedBinaryFilename)\n\t\t\t\t\t\terrs = multierror.Append(errs, err)\n\t\t\t\t\t\treturn nil, errs\n\t\t\t\t\t}\n\n\t\t\t\t\tvar outputFileData bytes.Buffer\n\t\t\t\t\tif _, err := io.Copy(&outputFileData, copyFrom); err != nil {\n\t\t\t\t\t\terr := fmt.Errorf(\"extract file: %w\", err)\n\t\t\t\t\t\terrs = multierror.Append(errs, err)\n\t\t\t\t\t\treturn nil, errs\n\t\t\t\t\t}\n\t\t\t\t\ttmpBinFileName := filepath.Join(os.TempDir(), expectedBinaryFilename)\n\t\t\t\t\ttmpOutputFile, err := os.OpenFile(tmpBinFileName, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0755)\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\terr = fmt.Errorf(\"could not create temporary file to download plugin: %w\", err)\n\t\t\t\t\t\terrs = multierror.Append(errs, err)\n\t\t\t\t\t\treturn nil, errs\n\t\t\t\t\t}\n\t\t\t\t\tdefer func() {\n\t\t\t\t\t\tos.Remove(tmpBinFileName)\n\t\t\t\t\t}()\n\n\t\t\t\t\tif _, err := tmpOutputFile.Write(outputFileData.Bytes()); err != nil {\n\t\t\t\t\t\terr := fmt.Errorf(\"extract file: %w\", err)\n\t\t\t\t\t\terrs = multierror.Append(errs, err)\n\t\t\t\t\t\treturn nil, errs","sourceCodeStart":856,"sourceCodeEnd":892,"githubUrl":"https://github.com/hashicorp/packer/blob/eb36e3c3e48a036f3e8cc94087636ee72e1303c9/packer/plugin-getter/plugins.go#L856-L892","documentation":"During plugin installation, Packer copies the extracted plugin binary out of the archive reader into an in-memory buffer (io.Copy). If that copy fails at any point, the underlying error is wrapped as \"extract file: %w\" and accumulated into a multierror returned by InstallLatest. This indicates the compressed archive stream could not be read/decoded for this member file.","triggerScenarios":"Calling InstallLatest (directly or via `packer plugins installed`/installFromServer) when the reader for a plugin archive member returns an error mid-copy: corrupt zip member, truncated download, or a reader that errors on Read.","commonSituations":"Corrupted plugin ZIP in the plugin cache or downloaded from a broken mirror/proxy; disk/network failure while streaming the archive; a malformed custom-built plugin binary packaged into the archive.","solutions":["Delete the corrupted plugin archive from Packer's plugin directory (~/.packer.d/plugins or PLUGIN_MIN_PORT config dir) and re-run the install so it re-downloads.","Verify connectivity/proxy settings if the archive was fetched from a remote registry; retry the install.","Check free disk space and that the download completed (compare archive size/checksum).","If using a custom plugin, rebuild and re-zip the plugin binary correctly.","Upgrade Packer; if persistent, file an issue with the wrapped (%w) inner error message."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// before install: sanity-check the cached/downloaded archive\nf, err := os.Open(archivePath)\nif err != nil { return err }\ndefer f.Close()\nzr, err := zip.NewReader(bufio.NewReader(f), archiveStat.Size())\nif err != nil { return fmt.Errorf(\"archive unreadable, delete and re-download: %w\", err) }\nfor _, zf := range zr.File {\n    rc, err := zf.Open()\n    if err != nil { return err }\n    _, _ = io.Copy(io.Discard, rc)\n    rc.Close()\n}","typeGuard":null,"tryCatchPattern":"err := getter.InstallLatest(ctx, req)\nif err != nil {\n    var merr *multierror.Error\n    if errors.As(err, &merr) {\n        for _, e := range merr.Errors {\n            if strings.Contains(e.Error(), \"extract file\") {\n                // purge corrupted archive and retry once\n                os.RemoveAll(pluginCacheDir)\n                return getter.InstallLatest(ctx, req)\n            }\n        }\n    }\n    return err\n}","preventionTips":["Use a reliable network path/registry mirror; avoid interrupted downloads of plugin archives.","Verify archive checksums when caching plugins offline.","Keep adequate disk space on the volume holding the plugin cache.","On failure, delete the specific plugin archive before retrying so corruption is not reused.","Pin plugin versions and test installs in CI before rolling to machines."],"tags":["go","plugin-install","archive","io"],"backgroundTag":"archive-extract-failed","analyzedSha":"eb36e3c3e48a036f3e8cc94087636ee72e1303c9","analyzedAt":"2026-09-05T13:20:43.127Z","contentChangedAt":"2026-09-05T13:20:43.127Z","schemaVersion":2},"datasetVersion":"2026-09-12T17:17:11.597Z"}