{"record":{"id":"f43edf0888d0a8ad","repo":"hashicorp/packer","slug":"the-bucket-name-must-be-specified-f43edf","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-version/data.go","lineNumber":49,"sourceCode":"\tBucketName string `mapstructure:\"bucket_name\" required:\"true\"`\n\t// The channel name in the given bucket to use for retrieving the version.\n\tChannelName string `mapstructure:\"channel_name\" required:\"true\"`\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.BucketName == \"\" {\n\t\terrs = packersdk.MultiErrorAppend(errs, fmt.Errorf(\"the `bucket_name` must be specified\"))\n\t}\n\tif d.config.ChannelName == \"\" {\n\t\terrs = packersdk.MultiErrorAppend(errs, fmt.Errorf(\"the `channel_name` must be specified\"))\n\t}\n\n\tif errs != nil && len(errs.Errors) > 0 {\n\t\treturn errs\n\t}\n\treturn nil\n}\n\n// DatasourceOutput is essentially a copy of []*models.HashicorpCloudPacker20230101Version, but without\n// the build and ancestry details\ntype DatasourceOutput struct {\n\t// Name of the author who created this version.\n\tAuthorID string `mapstructure:\"author_id\"`\n\n\t// The name of the bucket that this version is associated with.","sourceCodeStart":31,"sourceCodeEnd":67,"githubUrl":"https://github.com/hashicorp/packer/blob/eb36e3c3e48a036f3e8cc94087636ee72e1303c9/datasource/hcp-packer-version/data.go#L31-L67","documentation":"Configure-time validation for the hcp-packer-version datasource requires `bucket_name`. When d.config.BucketName is empty after decoding, this error is appended to a packersdk.MultiError and Configure fails before any API call. This datasource is the legacy/deprecated predecessor of hcp-packer-iteration.","triggerScenarios":"Running packer build with an hcp_packer_version data block missing the `bucket_name` attribute, or with a value that decodes to the empty string.","commonSituations":"Old HCL1-style templates migrated to HCL2 without bucket_name; variables interpolating to empty strings; partial copy from documentation examples.","solutions":["Add `bucket_name = \"<bucket-slug>\"` to the hcp_packer_version data block.","Fix the variable/expression feeding bucket_name so it resolves non-empty.","Prefer migrating to the hcp-packer-iteration datasource, as hcp-packer-version is deprecated."],"exampleFix":"// before\ndata \"hcp-packer-version\" \"ver\" {\n  channel_name = \"production\"\n}\n// after\ndata \"hcp-packer-version\" \"ver\" {\n  bucket_name  = \"my-app\"\n  channel_name = \"production\"\n}","handlingStrategy":"validation","validationCode":"// packer validate catches missing bucket_name at Configure time:\n// data \"hcp-packer-version\" \"ver\" { bucket_name = \"my-app\" channel_name = \"production\" }\n// CI: packer validate template.pkr.hcl","typeGuard":null,"tryCatchPattern":"packer validate template.pkr.hcl || { echo 'bucket_name required in hcp_packer_version data block'; exit 1; }","preventionTips":["Always include bucket_name in hcp_packer_version blocks.","Run `packer validate` in pre-commit/CI.","Avoid empty-string variable defaults for required attributes.","Plan migration to hcp-packer-iteration since hcp-packer-version is deprecated."],"tags":["hcp-packer","validation","config","deprecated"],"backgroundTag":"missing-required-argument","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"}