{"record":{"id":"4e0f38fec391fee2","repo":"hashicorp/packer","slug":"channel-is-currently-a-required-field","errorCode":null,"errorMessage":"`channel` is currently a required field.","messagePattern":"`channel` is currently a required field\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"datasource/hcp-packer-iteration/data.go","lineNumber":55,"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.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\"`\n\t// If true, this iteration is considered \"ready to use\" and will be\n\t// returned even if the include_incomplete flag is \"false\" in the\n\t// list iterations request. Note that if you are retrieving an iteration","sourceCodeStart":37,"sourceCodeEnd":73,"githubUrl":"https://github.com/hashicorp/packer/blob/eb36e3c3e48a036f3e8cc94087636ee72e1303c9/datasource/hcp-packer-iteration/data.go#L37-L73","documentation":"Configure-time validation for the hcp-packer-iteration datasource currently requires `channel` to be set. Empty Channel config yields this error appended to a MultiError. Note the wording ('currently') reflects that channel was made mandatory in this code path, unlike the image datasource which also accepts iteration_id.","triggerScenarios":"Running packer build with an hcp-packer-iteration datasource lacking the `channel` attribute (empty after decoding), alone or combined with the missing bucket_name error in a MultiError.","commonSituations":"Migrating a template from the deprecated hcp_packer_version data block to hcp-packer-iteration and omitting channel; assuming iteration-only lookups are supported here; variable defaulting to empty string.","solutions":["Add `channel = \"<channel-name>\"` to the hcp-packer-iteration datasource block.","If you do not have a channel, create one in HCP Packer and assign an iteration.","For iteration-only lookups of image metadata, use the hcp-packer-image datasource with `iteration_id` instead."],"exampleFix":"// before\ndata \"hcp-packer-iteration\" \"iter\" {\n  bucket_name = \"my-app\"\n}\n// after\ndata \"hcp-packer-iteration\" \"iter\" {\n  bucket_name = \"my-app\"\n  channel     = \"production\"\n}","handlingStrategy":"validation","validationCode":"// Ensure both required fields are present; packer validate catches this:\n// data \"hcp-packer-iteration\" \"iter\" { bucket_name = \"my-app\" channel = \"production\" }\n// CI: packer validate template.pkr.hcl","typeGuard":null,"tryCatchPattern":"packer validate template.pkr.hcl || { echo '`channel` required in hcp-packer-iteration datasource'; exit 1; }","preventionTips":["Include both bucket_name and channel in every hcp-packer-iteration block.","Remember channel is currently mandatory here; use hcp-packer-image with iteration_id for iteration-only lookups.","Run `packer validate` before committing templates.","When migrating from hcp-packer-version, map bucket_name -> bucket_name and channel_name -> channel."],"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"}