hashicorp/packer · error
failed to close %s stream from zip: %w
Error message
failed to close %s stream from zip: %w
What it means
Runtime error from extractBinaryFromZip: the scanner binary's zip entry stream could not be closed after reading. Data was likely read fine, but close failures are surfaced to avoid silently accepting a partially-consumed entry.
Source
Thrown at provisioner/hcp-sbom/provisioner.go:582
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,
}
if err := comm.Start(ctx, cmd); err != nil {
return fmt.Errorf("failed to start remote step %q: %s", step, err)
}View on GitHub (pinned to eb36e3c3e4)
Solutions
- Retry the build — close errors on zip streams are usually transient I/O issues
- Inspect the zip file integrity if the error persists
Defensive patterns
Strategy: retry
When it happens
Trigger: Thrown at provisioner/hcp-sbom/provisioner.go:582 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/dd97b1bd91af15db.
Report an issue: GitHub.