{"record":{"id":"db7c492c7a0d25de","repo":"hashicorp/packer","slug":"the-build-for-the-component-q-does-not-appear-to","errorCode":null,"errorMessage":"the build for the component %q does not appear to be a valid registry Build","messagePattern":"the build for the component %q does not appear to be a valid registry Build","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/hcp/registry/types.version.go","lineNumber":82,"sourceCode":"\n\treturn nil\n}\n\n// StoreBuild stores a build for buildName to an active version.\nfunc (version *Version) StoreBuild(buildName string, build *Build) {\n\tversion.builds.Store(buildName, build)\n}\n\n// Build gets the store build associated with buildName in the active version.\nfunc (version *Version) Build(buildName string) (*Build, error) {\n\tbuild, ok := version.builds.Load(buildName)\n\tif !ok {\n\t\treturn nil, errors.New(\"no associated build found for the name \" + buildName)\n\t}\n\n\tb, ok := build.(*Build)\n\tif !ok {\n\t\treturn nil, fmt.Errorf(\"the build for the component %q does not appear to be a valid registry Build\", buildName)\n\t}\n\n\treturn b, nil\n}\n\n// HasBuild checks if version has a stored build associated with buildName.\nfunc (version *Version) HasBuild(buildName string) bool {\n\t_, ok := version.builds.Load(buildName)\n\n\treturn ok\n}\n\n// AddArtifactToBuild appends one or more artifacts to the build referred to by buildName.\nfunc (version *Version) AddArtifactToBuild(buildName string, artifacts ...packerSDKRegistry.Image) error {\n\tbuild, err := version.Build(buildName)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"AddArtifactToBuild: %w\", err)\n\t}","sourceCodeStart":64,"sourceCodeEnd":100,"githubUrl":"https://github.com/hashicorp/packer/blob/eb36e3c3e48a036f3e8cc94087636ee72e1303c9/internal/hcp/registry/types.version.go#L64-L100","documentation":"Returned by Version.Build when the entry stored under buildName exists but is not a *Build. This indicates the version's internal build map holds an unexpected type — a programming/pointer-aliasing bug rather than a user error.","triggerScenarios":"version.builds[buildName] contains a non-*Build value while iterating or after concurrent mutation; reached from UpdateBuildStatus, uploadSbom, markBuildComplete, IsExpectingBuildForComponent, HeartbeatBuild, and doCompleteBuild.","commonSituations":"Concurrent modification of the version's build map without proper synchronization; custom code storing other types into version.builds; memory corruption via unsafe sharing across goroutines.","solutions":["Do not mutate version.builds directly; only use StoreBuild with *Build values","Check for data races around the Version object (run with -race)","Upgrade Packer if this occurs during a normal build — it indicates a Packer bug","Verify no plugin code inserts foreign types into the registry version"],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":"// Only insert builds via StoreBuild with *Build values\nversion.StoreBuild(name, &Build{ComponentType: name})","typeGuard":"func isRegistryBuild(v interface{}) (*Build, bool) {\n    b, ok := v.(*Build)\n    return b, ok\n}","tryCatchPattern":"b, err := version.Build(name)\nif err != nil && strings.Contains(err.Error(), \"does not appear to be a valid registry Build\") {\n    // internal state corruption: report bug, recreate the version\n}","preventionTips":["Never write to version.builds directly; use StoreBuild only","Guard Version objects against concurrent access (sync, -race)","Only pass *Build values into registry APIs"],"tags":["hcp-packer","type-assertion","internal-state"],"backgroundTag":"invalid-registry-build-type","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"}