{"record":{"id":"dbe463786b9df128","repo":"hashicorp/packer","slug":"region-is-currently-a-required-field","errorCode":null,"errorMessage":"`region` is currently a required field.","messagePattern":"`region` is currently a required field\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"datasource/hcp-packer-image/data.go","lineNumber":90,"sourceCode":"\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}\n\tif d.config.CloudProvider == \"\" {\n\t\terrs = packersdk.MultiErrorAppend(errs, fmt.Errorf(\"`cloud_provider` is \"+\n\t\t\t\"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 Information from []*hcpPackerDeprecatedModels.HashicorpCloudPackerImage with some information\n// from the parent []*hcpPackerDeprecatedModels.HashicorpCloudPackerBuild included where it seemed\n// like it might be relevant. Need to copy so we can generate\ntype DatasourceOutput struct {\n\t// The name of the cloud provider that the image exists in. For example,","sourceCodeStart":72,"sourceCodeEnd":108,"githubUrl":"https://github.com/hashicorp/packer/blob/eb36e3c3e48a036f3e8cc94087636ee72e1303c9/datasource/hcp-packer-image/data.go#L72-L108","documentation":"Validation error from Configure() of the hcp-packer-image datasource when d.config.Region is empty. Region is required because the datasource filters the iteration's builds down to the single image in the requested cloud region; without it no unique image can be selected. It is appended to a MultiError so it may appear alongside other validation failures.","triggerScenarios":"Configure() runs and region is missing from the data block, or an empty variable/local interpolates into it.","commonSituations":"Omitting region assuming it is optional; region provided only for some build-matrix legs; typos like 'regions' or 'cloud_region'; a variable with an empty default in CI.","solutions":["Add region = \"<cloud-region>\" (e.g. \"us-east-1\") to the data block.","Verify any variable feeding region resolves non-empty.","Use the exact region string the source build published.","Consider migrating to hcp-packer-artifact, which has the same region requirement."],"exampleFix":"// before\ndata \"hcp-packer-image\" \"example\" {\n  bucket_name = \"my-bucket\"\n  channel = \"production\"\n  cloud_provider = \"aws\"\n}\n// after\ndata \"hcp-packer-image\" \"example\" {\n  bucket_name = \"my-bucket\"\n  channel = \"production\"\n  cloud_provider = \"aws\"\n  region = \"us-east-1\"\n}","handlingStrategy":"validation","validationCode":"locals {\n  hcp_region = coalesce(var.hcp_region, \"us-east-1\")\n}\n# data \"hcp-packer-image\" \"example\" { region = local.hcp_region ... }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Run `packer validate` before builds; it collects this and sibling required-field errors at once.","Define region as a mandatory input variable without an empty default.","Use the exact region string the publishing build used."],"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"}