{"record":{"id":"ac349688152307cd","repo":"hashicorp/packer","slug":"newbuildfromcloudpackerbuild-w","errorCode":null,"errorMessage":"NewBuildFromCloudPackerBuild: %w","messagePattern":"NewBuildFromCloudPackerBuild: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/hcp/registry/types.builds.go","lineNumber":52,"sourceCode":"\tbuild := Build{\n\t\tID:            src.ID,\n\t\tComponentType: src.ComponentType,\n\t\tPlatform:      src.Platform,\n\t\tRunUUID:       src.PackerRunUUID,\n\t\tStatus:        *src.Status,\n\t\tLabels:        src.Labels,\n\t}\n\n\tvar err error\n\tfor _, artifact := range src.Artifacts {\n\t\terr = build.AddArtifacts(packerSDKRegistry.Image{\n\t\t\tImageID:        artifact.ExternalIdentifier,\n\t\t\tProviderName:   build.Platform,\n\t\t\tProviderRegion: artifact.Region,\n\t\t})\n\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"NewBuildFromCloudPackerBuild: %w\", err)\n\t\t}\n\t}\n\n\treturn &build, nil\n}\n\n// MergeLabels merges the contents of data to the labels associated with the build.\n// Duplicate keys will be updated to reflect the new value.\nfunc (build *Build) MergeLabels(data map[string]string) {\n\tif data == nil {\n\t\treturn\n\t}\n\n\tif build.Labels == nil {\n\t\tbuild.Labels = make(map[string]string)\n\t}\n\n\tfor k, v := range data {","sourceCodeStart":34,"sourceCodeEnd":70,"githubUrl":"https://github.com/hashicorp/packer/blob/eb36e3c3e48a036f3e8cc94087636ee72e1303c9/internal/hcp/registry/types.builds.go#L34-L70","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Validate the cloud build record before conversion\nfor _, a := range src.Artifacts {\n    if a.ExternalIdentifier == \"\" {\n        return fmt.Errorf(\"artifact on build %s has empty ExternalIdentifier\", src.ID)\n    }\n}","typeGuard":"func validCloudArtifacts(src *models.HashicorpCloudPacker20230101Build) bool {\n    for _, a := range src.Artifacts {\n        if a.ExternalIdentifier == \"\" || a.Region == \"\" { return false }\n    }\n    return true\n}","tryCatchPattern":null,"preventionTips":["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"],"tags":["hcp-packer","build","artifact-validation"],"backgroundTag":"artifact-validation-failed","analyzedSha":"eb36e3c3e48a036f3e8cc94087636ee72e1303c9","analyzedAt":"2026-09-05T13:20:43.127Z","contentChangedAt":"2026-09-05T13:20:43.127Z","schemaVersion":2},"datasetVersion":"2026-09-12T17:17:11.597Z"}