hashicorp/packer · error · NotAHCPArtifactError
No HCP Packer-compatible artifacts were found for the build
Error message
No HCP Packer-compatible artifacts were found for the build
What it means
This error is returned by Bucket.doCompleteBuild when the build record fetched from HCP Packer has no artifacts registered. The registry wraps it in NotAHCPArtifactError to signal that none of the produced artifacts were HCP Packer-compatible, so there is nothing to publish for this build.
Source
Thrown at internal/hcp/registry/types.bucket.go:804
log.Printf("[WARN] - artifact %q failed to be decoded to an HCP artifact, this is probably because it is not compatible: %s", art.BuilderId(), err)
continue
}
err = bucket.UpdateArtifactForBuild(buildName, sdkImages...)
if err != nil {
return packerSDKArtifacts, fmt.Errorf("failed to add artifact for %q: %s", buildName, err)
}
}
build, err := bucket.Version.Build(buildName)
if err != nil {
return packerSDKArtifacts, fmt.Errorf(
"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)
}
View on GitHub (pinned to eb36e3c3e4)
Solutions
- Verify the build's builders actually produce artifacts and that no artifact-stripping post-processor (e.g. manifest-only chains) removes them
- Check that each artifact implements the registry Image interface (valid ImageID/ProviderName) so it counts as HCP-compatible
- If the build intentionally has no artifacts, do not enable HCP Packer integration for that build
- Inspect the build in HCP Packer to confirm whether artifacts were expected; re-run the build if the builder silently failed
Defensive patterns
Strategy: validation
Validate before calling
// Before enabling HCP publishing for a template, ensure builders emit artifacts
if len(artifactList) == 0 {
return fmt.Errorf("build %q produced no artifacts; HCP publishing requires at least one", buildName)
} Prevention
- Do not combine HCP Packer publishing with artifact-free builders (null builder)
- Avoid post-processor chains that drop all artifacts before completion
- Confirm each artifact registers as a registry Image (implements the HCP-compatible interface)
When it happens
Trigger: doCompleteBuild fetches the build via bucket.getBuild and finds len(build.Artifacts)==0. This happens when the builder produced no artifacts, or when no artifact in the build registered itself as HCP-compatible (e.g. a null-builder or a builder that emits no registry Image).
Common situations: Running builds whose builders create no images (null builder, shell-only runs); using a custom/post-processor chain that strips artifacts; an HCP-visible build completing before any artifact was added via AddArtifactToBuild.
Related errors
- there is no iteration associated with the channel %s
- there is no iteration associated with the channel %s
- build failed, not uploading artifacts
- failed to update HCP Packer artifacts for %q: %s
- AddArtifacts: failed to add artifact to build %q: %w
AI-assisted analysis of hashicorp/packer@eb36e3c3e4 (2026-09-05).
Data as JSON: /api/errors/313f1818ff808cba.
Report an issue: GitHub.