{"record":{"id":"00a178ef67263998","repo":"hashicorp/packer","slug":"build-failed-not-uploading-artifacts","errorCode":null,"errorMessage":"build failed, not uploading artifacts","messagePattern":"build failed, not uploading artifacts","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/hcp/registry/types.bucket.go","lineNumber":744,"sourceCode":"\tif !ok {\n\t\tlog.Print(\"[ERROR] done build does not have an entry in the heartbeat table, state will be inconsistent.\")\n\t} else {\n\t\tlog.Printf(\"[TRACE] signal stopping heartbeats\")\n\t\t// Stop heartbeating\n\t\tdoneCh <- struct{}{}\n\t\tlog.Printf(\"[TRACE] stopped heartbeats\")\n\t}\n\n\tif buildErr != nil {\n\t\tstatus := hcpPackerModels.HashicorpCloudPacker20230101BuildStatusBUILDFAILED\n\t\tif ctx.Err() != nil {\n\t\t\tstatus = hcpPackerModels.HashicorpCloudPacker20230101BuildStatusBUILDCANCELLED\n\t\t}\n\t\terr := bucket.UpdateBuildStatus(context.Background(), buildName, status)\n\t\tif err != nil {\n\t\t\tlog.Printf(\"[ERROR] failed to update build %q status to FAILED: %s\", buildName, err)\n\t\t}\n\t\treturn packerSDKArtifacts, fmt.Errorf(\"build failed, not uploading artifacts\")\n\t}\n\n\tartifacts, err := bucket.doCompleteBuild(ctx, buildName, packerSDKArtifacts, ui, buildErr)\n\tif err != nil {\n\t\terr := bucket.UpdateBuildStatus(ctx, buildName, hcpPackerModels.HashicorpCloudPacker20230101BuildStatusBUILDFAILED)\n\t\tif err != nil {\n\t\t\tlog.Printf(\"[ERROR] failed to update build %q status to FAILED: %s\", buildName, err)\n\t\t}\n\t}\n\n\treturn artifacts, err\n}\n\nfunc (bucket *Bucket) doCompleteBuild(\n\tctx context.Context,\n\tbuildName string,\n\tpackerSDKArtifacts []packerSDK.Artifact,\n\tui packerSDK.Ui,","sourceCodeStart":726,"sourceCodeEnd":762,"githubUrl":"https://github.com/hashicorp/packer/blob/eb36e3c3e48a036f3e8cc94087636ee72e1303c9/internal/hcp/registry/types.bucket.go#L726-L762","documentation":"completeBuild is called when a build finishes. If the build itself errored (buildErr != nil), Packer marks the build FAILED (or CANCELLED if the context was cancelled) in HCP Packer and returns this error to signal that no artifacts will be uploaded to the registry. It is the user-facing consequence of the build failing, not a registry failure itself.","triggerScenarios":"Bucket.CompleteBuild -> completeBuild is invoked with a non-nil buildErr — i.e. the underlying builder/provisioner failed or the run context was cancelled — so completeBuild skips doCompleteBuild and returns \"build failed, not uploading artifacts\".","commonSituations":"Provisioner script failure; builder could not reach the source image or SSH; user pressed Ctrl-C (ctx cancelled -> CANCELLED status); CI timeout killing the run; any plugin error during the build.","solutions":["Read the build log above this error for the actual builder/provisioner failure and fix that root cause","If cancelled, re-run the build with adequate timeouts","Verify communicator connectivity (SSH/WinRM credentials, security groups) if provisioning failed","Re-run packer build after fixing; artifacts will upload once the build succeeds"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"// Go\nartifacts, err := bucket.CompleteBuild(ctx, buildName, arts, ui, buildErr)\nif err != nil {\n\tif strings.Contains(err.Error(), \"build failed, not uploading artifacts\") {\n\t\t// root cause is in buildErr — surface it, don't retry the upload\n\t\treturn fmt.Errorf(\"build failed upstream: %w\", buildErr)\n\t}\n\treturn err\n}","preventionTips":["Fix the underlying builder/provisioner error reported before this message","Set generous CI timeouts to avoid context cancellation mid-build","Validate provisioner scripts locally before registry-backed runs","Check communicator connectivity (SSH keys, security groups) before long builds"],"tags":["hcp-packer","build-failed","artifacts"],"backgroundTag":"build-failed-no-artifacts","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"}