{"record":{"id":"aeb2f217c72a9291","repo":"hashicorp/packer","slug":"the-bucket-name-must-be-specified-aeb2f2","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-iteration/data.go","lineNumber":52,"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\tif d.config.Channel == \"\" {\n\t\terrs = packersdk.MultiErrorAppend(errs, fmt.Errorf(\"`channel` is currently a required field.\"))\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.HashicorpCloudPackerIteration, but without the\n// []Builds or ancestor id.\ntype DatasourceOutput struct {\n\t// who created the iteration\n\tAuthorID string `mapstructure:\"author_id\"`\n\t// Name of the bucket that the iteration was retrieved from\n\tBucketName string `mapstructure:\"bucket_name\"`","sourceCodeStart":34,"sourceCodeEnd":70,"githubUrl":"https://github.com/hashicorp/packer/blob/eb36e3c3e48a036f3e8cc94087636ee72e1303c9/datasource/hcp-packer-iteration/data.go#L34-L70","documentation":"Configure-time validation for the hcp-packer-iteration datasource requires `bucket_name` to be non-empty. When the decoded config's Bucket field is empty, the error is appended to a packersdk.MultiError (so it may appear alongside the missing-channel error). Packer fails the datasource before any HCP API call is made.","triggerScenarios":"Running packer build with an hcp-packer-iteration datasource whose `bucket_name` attribute is absent, empty string, or set via an empty variable expression.","commonSituations":"Copy-pasted template where bucket_name was deleted; variable interpolation resolving to \"\"; renaming the bucket in HCP but forgetting to update the template; HCL2 block written with only `channel`.","solutions":["Add `bucket_name = \"<your-bucket-slug>\"` to the datasource block.","If it comes from a variable, give the variable a non-empty default or value.","Verify the bucket slug exists in your HCP Packer registry (`hcp packer buckets list`)."],"exampleFix":"// before\ndata \"hcp-packer-iteration\" \"iter\" {\n  channel = \"production\"\n}\n// after\ndata \"hcp-packer-iteration\" \"iter\" {\n  bucket_name = \"my-app\"\n  channel     = \"production\"\n}","handlingStrategy":"validation","validationCode":"// HCL: fail early on empty bucket_name\nvariable \"bucket_name\" {\n  type    = string\n  default = \"my-app\"\n}\n// locals check:\n// packer validate will surface the Configure error before any API call: run `packer validate template.pkr.hcl` in CI.","typeGuard":null,"tryCatchPattern":"// Run validation before build:\npacker validate template.pkr.hcl || { echo 'bucket_name missing in hcp-packer-iteration datasource'; exit 1; }","preventionTips":["Always set bucket_name with a non-empty literal or variable with a default.","Run `packer validate` in CI to catch missing required fields pre-build.","Keep a canonical datasource snippet and copy from it.","When using variables, avoid defaults of \"\" for required fields."],"tags":["hcp-packer","validation","config","datasource"],"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"}