hashicorp/packer · error
NewBuildFromCloudPackerBuild: %w
Error message
NewBuildFromCloudPackerBuild: %w
What it means
Wraps a Build.AddArtifacts validation failure that occurs while converting a HashicorpCloudPacker20230101Build (fetched from HCP) into the local registry Build type. An artifact on the remote build record failed Image validation during conversion.
Source
Thrown at internal/hcp/registry/types.builds.go:52
build := Build{
ID: src.ID,
ComponentType: src.ComponentType,
Platform: src.Platform,
RunUUID: src.PackerRunUUID,
Status: *src.Status,
Labels: src.Labels,
}
var err error
for _, artifact := range src.Artifacts {
err = build.AddArtifacts(packerSDKRegistry.Image{
ImageID: artifact.ExternalIdentifier,
ProviderName: build.Platform,
ProviderRegion: artifact.Region,
})
if err != nil {
return nil, fmt.Errorf("NewBuildFromCloudPackerBuild: %w", err)
}
}
return &build, nil
}
// MergeLabels merges the contents of data to the labels associated with the build.
// Duplicate keys will be updated to reflect the new value.
func (build *Build) MergeLabels(data map[string]string) {
if data == nil {
return
}
if build.Labels == nil {
build.Labels = make(map[string]string)
}
for k, v := range data {View on GitHub (pinned to eb36e3c3e4)
Solutions
- Check the offending build's artifacts in HCP Packer for empty ExternalIdentifier/Region values and fix or remove them
- Inspect the wrapped error (%w) to see which artifact field failed validation
- Delete and re-create the malformed build record in HCP Packer if it cannot be corrected
- Ensure the plugin version writing artifacts publishes valid identifiers
Defensive patterns
Strategy: validation
Validate before calling
// Validate the cloud build record before conversion
for _, a := range src.Artifacts {
if a.ExternalIdentifier == "" {
return fmt.Errorf("artifact on build %s has empty ExternalIdentifier", src.ID)
}
} Type guard
func validCloudArtifacts(src *models.HashicorpCloudPacker20230101Build) bool {
for _, a := range src.Artifacts {
if a.ExternalIdentifier == "" || a.Region == "" { return false }
}
return true
} Prevention
- Audit existing HCP bucket builds for empty external identifiers
- Keep builder plugins updated so identifiers are always populated
- Fix or delete malformed build records before re-populating versions
When it happens
Trigger: Called by CreateInitialBuildForVersion and populateVersion; for each artifact on the cloud build record, NewBuildFromCloudPackerBuild calls build.AddArtifacts with an Image built from artifact.ExternalIdentifier/Region — if Image.Validate fails (e.g. empty ImageID), the error is wrapped with this prefix.
Common situations: Remote HCP build records containing artifacts with empty external identifiers; malformed data in an existing bucket/version being populated; SDK/model changes leaving fields unset.
Related errors
- AddArtifacts: failed to add artifact to build %q: %w
- error retrieving version from HCP Packer Registry: %s
- error retrieving channel from HCP Packer Registry: %s
- there is no version associated with the channel %s
- the version %s is revoked and can not be used on Packer buil
AI-assisted analysis of hashicorp/packer@eb36e3c3e4 (2026-09-05).
Data as JSON: /api/errors/ac349688152307cd.
Report an issue: GitHub.