{"record":{"id":"93991e542499ba8e","repo":"hashicorp/packer","slug":"the-channel-name-must-be-specified","errorCode":null,"errorMessage":"the `channel_name` must be specified","messagePattern":"the `channel_name` must be specified","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"datasource/hcp-packer-version/data.go","lineNumber":52,"sourceCode":"}\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.\n\tBucketName string `mapstructure:\"bucket_name\"`\n\n\t// Current state of the version.","sourceCodeStart":34,"sourceCodeEnd":70,"githubUrl":"https://github.com/hashicorp/packer/blob/eb36e3c3e48a036f3e8cc94087636ee72e1303c9/datasource/hcp-packer-version/data.go#L34-L70","documentation":"Configure-time validation for the hcp-packer-version datasource requires `channel_name`. When d.config.ChannelName is empty after decoding, this error is appended to a MultiError (possibly alongside error 48) and the datasource fails at Configure time. Like error 48, this surfaces in the legacy hcp_packer_version data block.","triggerScenarios":"Running packer build with an hcp_packer_version data block lacking the `channel_name` attribute, or whose channel_name expression evaluates to empty string.","commonSituations":"Templates converted from JSON where only iteration lookup was used; channel renamed or deleted in HCP and the attribute removed; variable defaults left empty.","solutions":["Add `channel_name = \"<channel>\"` to the hcp_packer_version data block.","Ensure the referenced channel exists and has a release in the HCP Packer registry.","Migrate to hcp-packer-iteration (fields: bucket_name + channel), since hcp-packer-version is deprecated."],"exampleFix":"// before\ndata \"hcp-packer-version\" \"ver\" {\n  bucket_name = \"my-app\"\n}\n// after\ndata \"hcp-packer-version\" \"ver\" {\n  bucket_name  = \"my-app\"\n  channel_name = \"production\"\n}","handlingStrategy":"validation","validationCode":"// Ensure channel_name is set and non-empty before build:\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 'channel_name required in hcp_packer_version data block'; exit 1; }","preventionTips":["Always include channel_name in hcp_packer_version blocks.","Confirm the channel exists in the HCP registry and has a release.","Run `packer validate` before builds.","Migrate to the hcp-packer-iteration datasource (channel field) as 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"}