{"record":{"id":"71ad216935924f6e","repo":"hashicorp/packer","slug":"the-bucket-name-must-be-specified-71ad21","errorCode":null,"errorMessage":"The `bucket_name` must be specified","messagePattern":"The `bucket_name` must be specified","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"datasource/hcp-packer-image/data.go","lineNumber":74,"sourceCode":"\t// TODO: Version          string `mapstructure:\"version\"`\n\t// TODO: Fingerprint          string `mapstructure:\"fingerprint\"`\n\t// TODO: Label          string `mapstructure:\"label\"`\n}\n\nfunc (d *Datasource) ConfigSpec() hcldec.ObjectSpec {\n\treturn d.config.FlatMapstructure().HCL2Spec()\n}\n\nfunc (d *Datasource) Configure(raws ...interface{}) error {\n\terr := config.Decode(&d.config, nil, raws...)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tvar errs *packersdk.MultiError\n\n\tif d.config.Bucket == \"\" {\n\t\terrs = packersdk.MultiErrorAppend(errs, fmt.Errorf(\"The `bucket_name` must be specified\"))\n\t}\n\n\t// Ensure either channel or iteration_id are set, and not both at the same time\n\tif d.config.Channel == \"\" &&\n\t\td.config.IterationID == \"\" {\n\t\terrs = packersdk.MultiErrorAppend(errs, errors.New(\n\t\t\t\"The `iteration_id` or `channel` must be specified.\"))\n\t}\n\tif d.config.Channel != \"\" &&\n\t\td.config.IterationID != \"\" {\n\t\terrs = packersdk.MultiErrorAppend(errs, errors.New(\n\t\t\t\"`iteration_id` and `channel` cannot both be specified.\"))\n\t}\n\n\tif d.config.Region == \"\" {\n\t\terrs = packersdk.MultiErrorAppend(errs, fmt.Errorf(\"`region` is \"+\n\t\t\t\"currently a required field.\"))\n\t}","sourceCodeStart":56,"sourceCodeEnd":92,"githubUrl":"https://github.com/hashicorp/packer/blob/eb36e3c3e48a036f3e8cc94087636ee72e1303c9/datasource/hcp-packer-image/data.go#L56-L92","documentation":"Validation error raised in the hcp-packer-image datasource's Configure() when d.config.Bucket is empty. bucket_name identifies the HCP Packer Registry bucket whose images are queried; without it no registry request can be formed. Configure runs before Execute, so it surfaces immediately at validation time, bundled in a packersdk.MultiError.","triggerScenarios":"Configure() runs and the data block omits bucket_name, or the variable/local feeding it resolves to an empty string, or the attribute is misspelled so the field never gets a value.","commonSituations":"Copy-pasting a datasource block and forgetting bucket_name; an unset variable defaulting to \"\"; renaming the attribute during a refactor; interpolation that yields an empty string.","solutions":["Add bucket_name = \"<your-bucket>\" to the hcp-packer-image data block.","If supplied via a variable/local, verify it resolves non-empty (packer inspect / packer console help).","Check for attribute-name typos.","Migrate to hcp-packer-artifact — this datasource is deprecated and requires the same field."],"exampleFix":"// before\ndata \"hcp-packer-image\" \"example\" {\n  channel = \"production\"\n  region = \"us-east-1\"\n  cloud_provider = \"aws\"\n}\n// after\ndata \"hcp-packer-image\" \"example\" {\n  bucket_name = \"my-bucket\"\n  channel = \"production\"\n  region = \"us-east-1\"\n  cloud_provider = \"aws\"\n}","handlingStrategy":"validation","validationCode":"locals {\n  hcp_bucket = coalesce(var.hcp_bucket, \"default-bucket\") # or fail explicitly when unset\n}\n# Run `packer validate` in CI — it surfaces the MultiError before any build runs.","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always run `packer validate` in CI to catch required-field MultiErrors early.","Do not rename bucket_name to variants; HCL will not map unknown attributes.","Check interpolated variables for empty defaults."],"tags":["hcp-packer","config-validation","required-field","datasource"],"backgroundTag":"missing-required-config-field","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"}