{"record":{"id":"c159ab3018556791","repo":"hashicorp/packer","slug":"failed-to-resolve-expected-checksum-w","errorCode":null,"errorMessage":"failed to resolve expected checksum: %w","messagePattern":"failed to resolve expected checksum: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"provisioner/hcp-sbom/packer_release_fetch.go","lineNumber":256,"sourceCode":"\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\n\t\tactualSHA, err := fileSHA256(candidateZipPath)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tif !strings.EqualFold(expectedSHA, actualSHA) {\n\t\t\treturn fmt.Errorf(\"checksum mismatch for %s: expected %s, got %s\", fileName, expectedSHA, actualSHA)\n\t\t}\n\n\t\t// Validate the expected binary exists inside the archive.\n\t\tbinaryName := \"packer\"\n\t\tif goos == \"windows\" {\n\t\t\tbinaryName = \"packer.exe\"\n\t\t}\n\n\t\tzr, err := zip.OpenReader(candidateZipPath)","sourceCodeStart":238,"sourceCodeEnd":274,"githubUrl":"https://github.com/hashicorp/packer/blob/eb36e3c3e48a036f3e8cc94087636ee72e1303c9/provisioner/hcp-sbom/packer_release_fetch.go#L238-L274","documentation":"Wrapped when expectedZipSHA256FromSums cannot find a valid SHA256 entry for the target zip in the downloaded SHA256SUMS content. Either no line's filename matches packer_<v>_<goos>_<goarch>.zip (after trimming a leading '*'), or the matched hash is not 64 hex characters.","triggerScenarios":"expectedZipSHA256FromSums(sumsContent, fileName) returns an error: 'checksum for <file> not found in SHA256SUMS' because fileName is absent, or 'invalid SHA256 checksum format' because fields[0] fails isValidSHA256Hex.","commonSituations":"Version string from the index does not exactly match the artifacts published for that version (filename mismatch, e.g. naming scheme change); SHA256SUMS file format changed; corrupted/truncated checksums body; unusual GOOS/GOARCH with no published zip.","solutions":["Verify the SHA256SUMS file actually lists packer_<v>_<goos>_<goarch>.zip: curl the shaSumsURL and grep for the filename.","Check the exact version string being used in the URL (from logs) matches the artifacts published for that release.","Retry later if a release was just cut — artifacts and checksums can be briefly inconsistent.","If the format changed upstream, update Packer/the provisioner to a version with matching parsing logic."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"sums, err := fetch(sumsURL)\nline := fmt.Sprintf(\"%s  packer_%s_%s_%s.zip\", shaHex, v, goos, goarch)\nif !strings.Contains(sums, line) && !strings.Contains(sums, \"*packer_\"+v+\"_\"+goos+\"_\"+goarch+\".zip\") {\n\treturn fmt.Errorf(\"SHA256SUMS does not list an entry for %s/%s; artifacts may be unpublished\", goos, goarch)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Grep the SHA256SUMS for your exact filename before running the provisioner","Verify version/artifact consistency right after a release ships","Use widely supported GOOS/GOARCH pairs","Keep the provisioner/Packer versions current with upstream packaging"],"tags":["checksum","parsing","release-artifacts"],"backgroundTag":"checksum-not-found","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"}