hashicorp/packer · error

failed to open %s from zip: %w

Error message

failed to open %s from zip: %w

What it means

Runtime error from extractBinaryFromZip: the entry matching the scanner binary name was found in the zip, but opening its decompressed stream failed — typically internal archive corruption in that entry.

Source

Thrown at provisioner/hcp-sbom/provisioner.go:573

	return remotePath, nil
}

func extractBinaryFromZip(zipPath, binaryName string) ([]byte, error) {
	zr, err := zip.OpenReader(zipPath)
	if err != nil {
		return nil, fmt.Errorf("failed to open zip: %w", err)
	}
	defer func() { _ = zr.Close() }()

	for _, f := range zr.File {
		if f.Name != binaryName {
			continue
		}

		rc, err := f.Open()
		if err != nil {
			return nil, fmt.Errorf("failed to open %s from zip: %w", binaryName, err)
		}

		data, readErr := io.ReadAll(rc)
		closeErr := rc.Close()
		if readErr != nil {
			return nil, fmt.Errorf("failed to read %s from zip: %w", binaryName, readErr)
		}
		if closeErr != nil {
			return nil, fmt.Errorf("failed to close %s stream from zip: %w", binaryName, closeErr)
		}
		return data, nil
	}

	return nil, fmt.Errorf("%s not found in zip %s", binaryName, zipPath)
}

// runRemoteCmd runs a single shell command on the remote host and returns a
// descriptive error if it fails.

View on GitHub (pinned to eb36e3c3e4)

Solutions

  1. Retry the download to get an intact zip
  2. Inspect the zip entry manually to confirm it's not corrupted
Defensive patterns

Strategy: retry

When it happens

Trigger: Thrown at provisioner/hcp-sbom/provisioner.go:573 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of hashicorp/packer@eb36e3c3e4 (2026-09-05). Data as JSON: /api/errors/26bf69dd204fa35a. Report an issue: GitHub.