hashicorp/packer · error

do not use UpdateBuildStatus for updating to DONE

Error message

do not use UpdateBuildStatus for updating to DONE

What it means

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.

Source

Thrown at internal/hcp/registry/types.bucket.go:267

	// Initial build labels are only pushed to the registry when an actual Packer run is executed on the said build.
	// For example filtered builds (e.g --only or except) will not get the initial build labels until a build is
	// executed on them.
	// Global build label updates to existing builds are handled in PopulateVersion.
	if len(bucket.BuildLabels) > 0 {
		build.MergeLabels(bucket.BuildLabels)
	}
	bucket.Version.StoreBuild(componentType, build)

	return nil
}

// UpdateBuildStatus updates the status of a build entry on the HCP Packer registry with its current local status.
// For updating a build status to DONE use CompleteBuild.
func (bucket *Bucket) UpdateBuildStatus(
	ctx context.Context, name string, status hcpPackerModels.HashicorpCloudPacker20230101BuildStatus,
) error {
	if status == hcpPackerModels.HashicorpCloudPacker20230101BuildStatusBUILDDONE {
		return fmt.Errorf("do not use UpdateBuildStatus for updating to DONE")
	}

	buildToUpdate, err := bucket.Version.Build(name)
	if err != nil {
		return err
	}

	if buildToUpdate.ID == "" {
		return fmt.Errorf("the build for the component %q does not have a valid id", name)
	}

	if buildToUpdate.Status == hcpPackerModels.HashicorpCloudPacker20230101BuildStatusBUILDDONE {
		return fmt.Errorf("cannot modify status of DONE build %s", name)
	}

	_, err = bucket.client.UpdateBuild(ctx,
		bucket.Name,
		bucket.Version.Fingerprint,

View on GitHub (pinned to eb36e3c3e4)

Solutions

  1. Call bucket.CompleteBuild (markBuildComplete) to finish a build instead of UpdateBuildStatus with BUILD_DONE
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at internal/hcp/registry/types.bucket.go:267 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of hashicorp/packer@eb36e3c3e4 (2026-09-05). Data as JSON: /api/errors/d67717cc45af5605. Report an issue: GitHub.