{"record":{"id":"dd97b1bd91af15db","repo":"hashicorp/packer","slug":"failed-to-close-s-stream-from-zip-w","errorCode":null,"errorMessage":"failed to close %s stream from zip: %w","messagePattern":"failed to close (.+?) stream from zip: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"provisioner/hcp-sbom/provisioner.go","lineNumber":582,"sourceCode":"\tdefer func() { _ = zr.Close() }()\n\n\tfor _, f := range zr.File {\n\t\tif f.Name != binaryName {\n\t\t\tcontinue\n\t\t}\n\n\t\trc, err := f.Open()\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"failed to open %s from zip: %w\", binaryName, err)\n\t\t}\n\n\t\tdata, readErr := io.ReadAll(rc)\n\t\tcloseErr := rc.Close()\n\t\tif readErr != nil {\n\t\t\treturn nil, fmt.Errorf(\"failed to read %s from zip: %w\", binaryName, readErr)\n\t\t}\n\t\tif closeErr != nil {\n\t\t\treturn nil, fmt.Errorf(\"failed to close %s stream from zip: %w\", binaryName, closeErr)\n\t\t}\n\t\treturn data, nil\n\t}\n\n\treturn nil, fmt.Errorf(\"%s not found in zip %s\", binaryName, zipPath)\n}\n\n// runRemoteCmd runs a single shell command on the remote host and returns a\n// descriptive error if it fails.\nfunc (p *Provisioner) runRemoteCmd(ctx context.Context, comm packersdk.Communicator, cmdStr, step string) error {\n\tvar stderr bytes.Buffer\n\tcmd := &packersdk.RemoteCmd{\n\t\tCommand: cmdStr,\n\t\tStderr:  &stderr,\n\t}\n\tif err := comm.Start(ctx, cmd); err != nil {\n\t\treturn fmt.Errorf(\"failed to start remote step %q: %s\", step, err)\n\t}","sourceCodeStart":564,"sourceCodeEnd":600,"githubUrl":"https://github.com/hashicorp/packer/blob/eb36e3c3e48a036f3e8cc94087636ee72e1303c9/provisioner/hcp-sbom/provisioner.go#L564-L600","documentation":"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.","triggerScenarios":"Thrown at provisioner/hcp-sbom/provisioner.go:582 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Retry the build — close errors on zip streams are usually transient I/O issues","Inspect the zip file integrity if the error persists"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}