{"record":{"id":"4040d8386238a573","repo":"hashicorp/packer","slug":"failed-to-update-hcp-packer-artifacts-for-q-s","errorCode":null,"errorMessage":"failed to update HCP Packer artifacts for %q: %s","messagePattern":"failed to update HCP Packer artifacts for %q: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/hcp/registry/types.bucket.go","lineNumber":817,"sourceCode":"\t\t\t\"failed to get build %q from version being built. This is a Packer bug.\",\n\t\t\tbuildName)\n\t}\n\tif len(build.Artifacts) == 0 {\n\t\treturn packerSDKArtifacts, &NotAHCPArtifactError{\n\t\t\tfmt.Errorf(\"No HCP Packer-compatible artifacts were found for the build\"),\n\t\t}\n\t}\n\n\tfor _, sbom := range build.CompressedSboms {\n\t\terr = bucket.uploadSbom(ctx, buildName, sbom)\n\t\tif err != nil {\n\t\t\treturn packerSDKArtifacts, fmt.Errorf(\"Failed to upload sboms %s\", err)\n\t\t}\n\t}\n\n\tparErr := bucket.markBuildComplete(ctx, buildName)\n\tif parErr != nil {\n\t\treturn packerSDKArtifacts, fmt.Errorf(\n\t\t\t\"failed to update HCP Packer artifacts for %q: %s\",\n\t\t\tbuildName,\n\t\t\tparErr)\n\t}\n\n\t// Update channels after build is marked complete\n\tchannelErr := bucket.updateChannels(ctx, ui)\n\tif channelErr != nil {\n\t\tlog.Printf(\"[ERROR] Failed to update channels after completing build %s: %s\", buildName, channelErr)\n\t}\n\n\treturn append(packerSDKArtifacts, &registryArtifact{\n\t\tBuildName:  buildName,\n\t\tBucketName: bucket.Name,\n\t\tVersionID:  bucket.Version.ID,\n\t}), nil\n}\n","sourceCodeStart":799,"sourceCodeEnd":835,"githubUrl":"https://github.com/hashicorp/packer/blob/eb36e3c3e48a036f3e8cc94087636ee72e1303c9/internal/hcp/registry/types.bucket.go#L799-L835","documentation":"Wraps an error from bucket.markBuildComplete when transitioning the build to DONE in HCP Packer. The local build finished, but updating the HCP Packer artifacts/build state failed, so the registry entry remains incomplete.","triggerScenarios":"doCompleteBuild calls markBuildComplete after uploading SBOMs; any PAR/API error returned is wrapped as 'failed to update HCP Packer artifacts for %q: %s'.","commonSituations":"HCP API downtime or rate limiting at end of a long build; auth token expiring mid-run; concurrent Packer runs writing to the same bucket/version; version already marked complete by another process.","solutions":["Re-run the build or use 'packer publish' semantics to retry the completion update","Check HCP service status and credentials; re-authenticate if tokens expired","Ensure only one Packer run targets the same bucket/fingerprint concurrently","Read the wrapped parErr text for the specific API status (409/403/500 etc.) and act accordingly"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"err := doBuild()\nif err != nil && strings.Contains(err.Error(), \"failed to update HCP Packer artifacts\") {\n    // transient HCP API failure at completion: re-run or retry publish\n    retryWithBackoff(func() error { return republish() })\n}","preventionTips":["Avoid concurrent Packer runs on the same bucket/fingerprint","Use fresh credentials for builds longer than token lifetimes","Monitor HCP API status during release pipelines"],"tags":["hcp-packer","registry","api"],"backgroundTag":"hcp-build-complete-update-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"}