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, ®istryArtifact{
BuildName: buildName,
BucketName: bucket.Name,
VersionID: bucket.Version.ID,
}), nil
}
View on GitHub (pinned to eb36e3c3e4)
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
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
- 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
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
- there is no iteration associated with the channel %s
- error retrieving iteration from HCP Packer registry: %s
- there is no iteration associated with the channel %s
- No HCP Packer-compatible artifacts were found for the build
- AddArtifacts: failed to add artifact to build %q: %w
AI-assisted analysis of hashicorp/packer@eb36e3c3e4 (2026-09-05).
Data as JSON: /api/errors/4040d8386238a573.
Report an issue: GitHub.