{"record":{"id":"50faf7d5437de349","repo":"hashicorp/packer","slug":"failed-to-download-packer-release-zip-w","errorCode":null,"errorMessage":"failed to download Packer release zip: %w","messagePattern":"failed to download Packer release zip: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"provisioner/hcp-sbom/packer_release_fetch.go","lineNumber":240,"sourceCode":"\terr := retry.Config{\n\t\tTries:      3,\n\t\tRetryDelay: func() time.Duration { return 5 * time.Second },\n\t}.Run(ctx, func(ctx context.Context) error {\n\t\t// Resolve the latest stable version from the releases index.\n\t\tv, err := fetchLatestPackerVersion(ctx, client)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"failed to determine latest Packer version: %w\", err)\n\t\t}\n\n\t\tfileName := fmt.Sprintf(\"packer_%s_%s_%s.zip\", v, goos, goarch)\n\t\tzipURL := fmt.Sprintf(\"%s/packer/%s/%s\", base, v, fileName)\n\t\tshaSumsURL := fmt.Sprintf(\"%s/packer/%s/packer_%s_SHA256SUMS\", base, v, v)\n\n\t\tlog.Printf(\"[INFO] Downloading and verifying Packer %s for %s/%s...\", v, goos, goarch)\n\n\t\tcandidateZipPath, err := downloadURLToTempFile(ctx, client, zipURL, \".zip\")\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"failed to download Packer release zip: %w\", err)\n\t\t}\n\t\tkeepCandidate := false\n\t\tdefer func() {\n\t\t\tif !keepCandidate {\n\t\t\t\t_ = os.Remove(candidateZipPath)\n\t\t\t}\n\t\t}()\n\n\t\tsumsContent, err := downloadChecksumFile(ctx, client, shaSumsURL)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"failed to download release checksums: %w\", err)\n\t\t}\n\n\t\texpectedSHA, err := expectedZipSHA256FromSums(sumsContent, fileName)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"failed to resolve expected checksum: %w\", err)\n\t\t}\n","sourceCodeStart":222,"sourceCodeEnd":258,"githubUrl":"https://github.com/hashicorp/packer/blob/eb36e3c3e48a036f3e8cc94087636ee72e1303c9/provisioner/hcp-sbom/packer_release_fetch.go#L222-L258","documentation":"Wrapped when downloadURLToTempFile fails to download the Packer release zip (e.g. packer_<v>_<goos>_<goarch>.zip) into a temp file. Covers temp-file creation errors, HTTP request errors, non-200 status, and write/close failures. The partial temp file is removed automatically; the retry.Config wrapper retries up to 3 times.","triggerScenarios":"downloadURLToTempFile(ctx, client, zipURL, \".zip\") errors: os.CreateTemp fails, http request fails, HTTP status != 200 for the zip URL, io.Copy write error, or f.Close error.","commonSituations":"Wrong GOOS/GOARCH combination producing a nonexistent artifact URL (HTTP 404); disk full or read-only /tmp so os.CreateTemp fails; interrupted download mid-transfer; proxy blocking the artifact URL; newly released version whose zip is not yet propagated on the CDN.","solutions":["Check the exact zip URL in the error/logs exists (curl -I); a 404 usually means a transient index/artifact mismatch — retry the build.","Free disk space or fix TMPDIR permissions on the build host.","Verify network/proxy access to releases.hashicorp.com.","Confirm the target platform has an official Packer build for that GOOS/GOARCH."],"exampleFix":"// caller-side pre-check before invoking the auto-download flow\nif out, err := exec.Command(\"df\", \"-h\", os.TempDir()).Output(); err == nil {\n\tlog.Println(\"tmp space:\\n\", string(out)) // ensure room for the ~150MB zip\n}","handlingStrategy":"retry","validationCode":"url := fmt.Sprintf(\"https://releases.hashicorp.com/packer/%s/packer_%s_%s_%s.zip\", v, v, goos, goarch)\nresp, err := http.Head(url)\nif err != nil || resp.StatusCode != http.StatusOK {\n\treturn fmt.Errorf(\"zip artifact not available: HTTP status issue for %s\", url)\n}\nresp.Body.Close()","typeGuard":null,"tryCatchPattern":"if err := provisioner.Provision(...); err != nil {\n\tif strings.Contains(err.Error(), \"failed to download Packer release zip\") {\n\t\t// check disk space (TMPDIR) and network, then retry once\n\t}\n}","preventionTips":["Keep TMPDIR with several hundred MB free","Confirm the GOOS/GOARCH pair has an official Packer build","Warm CDN/proxy caches before mass CI runs","Retry builds that fail only on this download step"],"tags":["network","http","download","filesystem"],"backgroundTag":"artifact-download-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"}