hashicorp/packer · error

failed to update HCP Packer artifacts for %q: %s

Error message

failed to update HCP Packer artifacts for %q: %s

What it means

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.

Source

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

			"failed to get build %q from version being built. This is a Packer bug.",
			buildName)
	}
	if len(build.Artifacts) == 0 {
		return packerSDKArtifacts, &NotAHCPArtifactError{
			fmt.Errorf("No HCP Packer-compatible artifacts were found for the build"),
		}
	}

	for _, sbom := range build.CompressedSboms {
		err = bucket.uploadSbom(ctx, buildName, sbom)
		if err != nil {
			return packerSDKArtifacts, fmt.Errorf("Failed to upload sboms %s", err)
		}
	}

	parErr := bucket.markBuildComplete(ctx, buildName)
	if parErr != nil {
		return packerSDKArtifacts, fmt.Errorf(
			"failed to update HCP Packer artifacts for %q: %s",
			buildName,
			parErr)
	}

	// Update channels after build is marked complete
	channelErr := bucket.updateChannels(ctx, ui)
	if channelErr != nil {
		log.Printf("[ERROR] Failed to update channels after completing build %s: %s", buildName, channelErr)
	}

	return append(packerSDKArtifacts, &registryArtifact{
		BuildName:  buildName,
		BucketName: bucket.Name,
		VersionID:  bucket.Version.ID,
	}), nil
}

View on GitHub (pinned to eb36e3c3e4)

Solutions

  1. Re-run the build or use 'packer publish' semantics to retry the completion update
  2. Check HCP service status and credentials; re-authenticate if tokens expired
  3. Ensure only one Packer run targets the same bucket/fingerprint concurrently
  4. Read the wrapped parErr text for the specific API status (409/403/500 etc.) and act accordingly
Defensive patterns

Strategy: retry

Try / catch

err := doBuild()
if err != nil && strings.Contains(err.Error(), "failed to update HCP Packer artifacts") {
    // transient HCP API failure at completion: re-run or retry publish
    retryWithBackoff(func() error { return republish() })
}

Prevention

When it happens

Trigger: doCompleteBuild calls markBuildComplete after uploading SBOMs; any PAR/API error returned is wrapped as 'failed to update HCP Packer artifacts for %q: %s'.

Common situations: 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.

Related errors


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