{"record":{"id":"72d983b1d47c8f28","repo":"hashicorp/packer","slug":"failed-to-upload-packer-release-zip-s","errorCode":null,"errorMessage":"failed to upload Packer release zip: %s","messagePattern":"failed to upload Packer release zip: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"provisioner/hcp-sbom/provisioner.go","lineNumber":509,"sourceCode":"\t} else {\n\t\tbinaryName = \"packer\"\n\t\tremotePath = \"/tmp/packer-sbom-runner\"\n\t}\n\n\tif isWindows {\n\t\tremoteDir := \"C:\\\\Windows\\\\Temp\"\n\t\tremoteZipPath := remoteDir + \"\\\\packer-sbom-runner.zip\"\n\n\t\t// Step 1: upload zip to remote.\n\t\tzipFile, err := os.Open(localZipPath)\n\t\tif err != nil {\n\t\t\treturn \"\", fmt.Errorf(\"failed to open Packer release zip: %s\", err)\n\t\t}\n\t\tdefer func() { _ = zipFile.Close() }()\n\n\t\tlog.Printf(\"[INFO] Uploading Packer release zip to %s...\", remoteZipPath)\n\t\tif err := comm.Upload(remoteZipPath, zipFile, nil); err != nil {\n\t\t\treturn \"\", fmt.Errorf(\"failed to upload Packer release zip: %s\", err)\n\t\t}\n\n\t\t// Single PowerShell command: extract, move binary, remove zip.\n\t\tpsCmd := fmt.Sprintf(\n\t\t\t`powershell -NoProfile -ExecutionPolicy Bypass -Command `+\n\t\t\t\t`\"$ErrorActionPreference='Stop'; `+\n\t\t\t\t`Expand-Archive -Path '%s' -DestinationPath '%s' -Force; `+\n\t\t\t\t`if (!(Test-Path '%s\\%s')) { throw 'packer.exe not found after extraction' }; `+\n\t\t\t\t`Move-Item -Force '%s\\%s' '%s'; `+\n\t\t\t\t`Remove-Item -Force '%s'\"`,\n\t\t\tremoteZipPath, remoteDir,\n\t\t\tremoteDir, binaryName,\n\t\t\tremoteDir, binaryName, remotePath,\n\t\t\tremoteZipPath,\n\t\t)\n\t\tif err := p.runRemoteCmd(ctx, comm, psCmd, \"extract scanner (Windows)\"); err != nil {\n\t\t\treturn \"\", err\n\t\t}","sourceCodeStart":491,"sourceCodeEnd":527,"githubUrl":"https://github.com/hashicorp/packer/blob/eb36e3c3e48a036f3e8cc94087636ee72e1303c9/provisioner/hcp-sbom/provisioner.go#L491-L527","documentation":"This error wraps a failure of comm.Upload when copying the Packer release zip from the host to C:\\Windows\\Temp\\packer-sbom-runner.zip on the Windows guest. It is thrown at provisioner/hcp-sbom/provisioner.go:509 in uploadScanner (Windows path), called by provisionWithNativeGeneration. It indicates the communicator (typically WinRM) accepted the operation but the transfer failed, with the underlying transport error embedded.","triggerScenarios":"comm.Upload(remoteZipPath, zipFile, nil) returns an error during the Windows branch of uploadScanner — e.g. WinRM/SSH connection dropped mid-transfer, authentication failure, guest disk full in C:\\Windows\\Temp, or a timeout uploading a large zip.","commonSituations":"Unstable or slow WinRM connectivity to the Windows VM; the guest ran out of disk space in C:\\Windows\\Temp; wrong WinRM credentials/ports in the communicator block; security software on the guest blocking writes to Windows\\Temp; transfer timeouts on large release zips over high-latency networks.","solutions":["Check PACKER_LOG=1 output for the wrapped communicator error and fix the root transport issue (connection, auth, timeout).","Increase the communicator timeout (winrm_timeout) and retry the build — large uploads over slow networks often need more time.","Confirm the Windows guest has free disk space in C:\\Windows\\Temp and that no antivirus/EDR blocks Packer writing there.","Verify WinRM connectivity and credentials (winrm_username/winrm_password, port 5985/5986) before the build.","Retry the build; transient network drops during upload are a common cause and a fresh run may succeed."],"exampleFix":"// before\nsource \"null\" \"win\" {\n  communicator = \"winrm\"\n  winrm_timeout = \"30m\" // may be too short for big zips\n}\n// after\nsource \"null\" \"win\" {\n  communicator  = \"winrm\"\n  winrm_timeout = \"2h\"\n  winrm_use_ntlm = true\n}","handlingStrategy":"retry","validationCode":"// before build: confirm WinRM reachable\ntimeout := 10 * time.Second\nconn, err := net.DialTimeout(\"tcp\", fmt.Sprintf(\"%s:5985\", guestHost), timeout)\nif err != nil {\n\treturn fmt.Errorf(\"WinRM not reachable on %s:5985: %w\", guestHost, err)\n}\nconn.Close()\n// confirm disk space on guest during provisioning\ndfCmd := `powershell -Command \"(Get-PSDrive C).Free\"`","typeGuard":null,"tryCatchPattern":"err := comm.Upload(remoteZipPath, zipFile, nil)\nif err != nil {\n\tvar netErr net.Error\n\tif errors.As(err, &netErr) && netErr.Timeout() {\n\t\t// increase winrm_timeout and retry upload\n\t}\n\treturn fmt.Errorf(\"failed to upload Packer release zip: %w\", err)\n}","preventionTips":["Set a generous winrm_timeout sized for your zip size and network bandwidth.","Pre-check guest disk free space in C:\\Windows\\Temp in an early provisioner step.","Validate WinRM credentials and firewall rules (5985/5986) before long builds.","Retry transient upload failures with backoff rather than failing the whole build.","Keep release zips small or host the binary on a local mirror to reduce transfer time."],"tags":["network","upload","windows","winrm","communicator"],"backgroundTag":"file-upload-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"}