{"record":{"id":"d67717cc45af5605","repo":"hashicorp/packer","slug":"do-not-use-updatebuildstatus-for-updating-to-done","errorCode":null,"errorMessage":"do not use UpdateBuildStatus for updating to DONE","messagePattern":"do not use UpdateBuildStatus for updating to DONE","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/hcp/registry/types.bucket.go","lineNumber":267,"sourceCode":"\t// Initial build labels are only pushed to the registry when an actual Packer run is executed on the said build.\n\t// For example filtered builds (e.g --only or except) will not get the initial build labels until a build is\n\t// executed on them.\n\t// Global build label updates to existing builds are handled in PopulateVersion.\n\tif len(bucket.BuildLabels) > 0 {\n\t\tbuild.MergeLabels(bucket.BuildLabels)\n\t}\n\tbucket.Version.StoreBuild(componentType, build)\n\n\treturn nil\n}\n\n// UpdateBuildStatus updates the status of a build entry on the HCP Packer registry with its current local status.\n// For updating a build status to DONE use CompleteBuild.\nfunc (bucket *Bucket) UpdateBuildStatus(\n\tctx context.Context, name string, status hcpPackerModels.HashicorpCloudPacker20230101BuildStatus,\n) error {\n\tif status == hcpPackerModels.HashicorpCloudPacker20230101BuildStatusBUILDDONE {\n\t\treturn fmt.Errorf(\"do not use UpdateBuildStatus for updating to DONE\")\n\t}\n\n\tbuildToUpdate, err := bucket.Version.Build(name)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif buildToUpdate.ID == \"\" {\n\t\treturn fmt.Errorf(\"the build for the component %q does not have a valid id\", name)\n\t}\n\n\tif buildToUpdate.Status == hcpPackerModels.HashicorpCloudPacker20230101BuildStatusBUILDDONE {\n\t\treturn fmt.Errorf(\"cannot modify status of DONE build %s\", name)\n\t}\n\n\t_, err = bucket.client.UpdateBuild(ctx,\n\t\tbucket.Name,\n\t\tbucket.Version.Fingerprint,","sourceCodeStart":249,"sourceCodeEnd":285,"githubUrl":"https://github.com/hashicorp/packer/blob/eb36e3c3e48a036f3e8cc94087636ee72e1303c9/internal/hcp/registry/types.bucket.go#L249-L285","documentation":"API-misuse guard in Bucket.UpdateBuildStatus: the caller tried to set a build's status to DONE. DONE transitions have extra semantics (artifact/rollout checks) and must go through CompleteBuild instead.","triggerScenarios":"Thrown at internal/hcp/registry/types.bucket.go:267 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Call bucket.CompleteBuild (markBuildComplete) to finish a build instead of UpdateBuildStatus with BUILD_DONE"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}