{"record":{"id":"d933d8efd17b982a","repo":"hashicorp/packer","slug":"no-packer-bucket-name-defined-either-the-environm","errorCode":null,"errorMessage":"no Packer bucket name defined; either the environment variable %q is undefined or the HCL configuration has no build name","messagePattern":"no Packer bucket name defined; either the environment variable %q is undefined or the HCL configuration has no build name","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/hcp/registry/types.bucket.go","lineNumber":78,"sourceCode":"}\n\n// NewBucketWithVersion initializes a simple Bucket that can be used for publishing Packer build artifacts\n// to the HCP Packer registry.\nfunc NewBucketWithVersion() *Bucket {\n\tb := Bucket{\n\t\tBucketLabels:                             make(map[string]string),\n\t\tBuildLabels:                              make(map[string]string),\n\t\tSourceExternalIdentifierToParentVersions: make(map[string]ParentVersion),\n\t\tRunningBuilds:                            make(map[string]chan struct{}),\n\t}\n\tb.Version = NewVersion()\n\n\treturn &b\n}\n\nfunc (bucket *Bucket) Validate() error {\n\tif bucket.Name == \"\" {\n\t\treturn fmt.Errorf(\n\t\t\t\"no Packer bucket name defined; either the environment variable %q is undefined or \"+\n\t\t\t\t\"the HCL configuration has no build name\",\n\t\t\tenv.HCPPackerBucket,\n\t\t)\n\t}\n\treturn nil\n}\n\n// ReadFromHCLBuildBlock reads the information for initialising a Bucket from a HCL2 build block\nfunc (bucket *Bucket) ReadFromHCLBuildBlock(build *hcl2template.BuildBlock) {\n\tregistryBlock := build.HCPPackerRegistry\n\tif registryBlock == nil {\n\t\treturn\n\t}\n\tbucket.ReadFromHCPPackerRegistryBlock(build.HCPPackerRegistry)\n}\n\n// ReadFromHCPPackerRegistryBlock reads the information for initialising a Bucket from a HCL2 Packer registry block","sourceCodeStart":60,"sourceCodeEnd":96,"githubUrl":"https://github.com/hashicorp/packer/blob/eb36e3c3e48a036f3e8cc94087636ee72e1303c9/internal/hcp/registry/types.bucket.go#L60-L96","documentation":"HCP registry validation error from Bucket.Validate: the bucket name is empty because neither HCP_PACKER_BUCKET_NAME is set nor a build name exists in the HCL configuration, so there is no registry image to publish to.","triggerScenarios":"Thrown at internal/hcp/registry/types.bucket.go:78 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Add a bucket_name to the packer block in your HCL template","Set the HCP_PACKER_BUCKET_NAME environment variable","Name your build so a bucket slug can be derived from it"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}