hashicorp/packer · error
failed to read %s from zip: %w
Error message
failed to read %s from zip: %w
What it means
extractBinaryFromZip scans the SBOM scanner tool's zip archive for the scanner binary and streams it out. This error wraps an io.Read failure on the matched zip entry — the archive entry exists and opened, but its decompressed bytes could not be read (truncated/corrupt archive, I/O error). The wrapped cause identifies the underlying problem; re-download or replace the scanner zip.
Source
Thrown at provisioner/hcp-sbom/provisioner.go:579
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.
func (p *Provisioner) runRemoteCmd(ctx context.Context, comm packersdk.Communicator, cmdStr, step string) error {
var stderr bytes.Buffer
cmd := &packersdk.RemoteCmd{
Command: cmdStr,
Stderr: &stderr,
}View on GitHub (pinned to eb36e3c3e4)
Solutions
- Retry the build to obtain a fresh download
- Check for failing disks or flaky network if it recurs
Defensive patterns
Strategy: retry
When it happens
Trigger: Thrown at provisioner/hcp-sbom/provisioner.go:579 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/44518195ceff4fe9.
Report an issue: GitHub.