You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
If you are interested in working on this issue or have submitted a pull request, please leave a comment
Overview of the Issue
Running packer validate on an otherwise validate build template the contains an hcp-packer-image data source block causes Packer to crash. Running a build on the template does not result in the same error.
This issue does not exist in v1.8.0 - main culprit for this issue is likely #11832
Reproduction Steps
Run packer validate on template.
Packer version
v1.8.2
Simplified Packer Template
data"hcp-packer-iteration""centos7-base" {
bucket_name=var.hcp_bucket_namechannel=var.hcp_channel_name
}
data"hcp-packer-image""centos7-base" {
bucket_name=data.hcp-packer-iteration.centos7-base.bucket_nameiteration_id=data.hcp-packer-iteration.centos7-base.idcloud_provider="aws"region=var.region
}
source"amazon-ebs""centos7-web" {
ami_name="${var.prefix}-centos7-web-${local.timestamp}"ami_regions=["${var.region}", "eu-west-1", "eu-north-1"]
instance_type="t2.micro"region=var.regionsource_ami=data.hcp-packer-image.centos7-base.idssh_username=var.ssh_usernamessh_private_key_file=var.ssh_private_key_filessh_keypair_name=var.ssh_keypair_name
}
build {
hcp_packer_registry {
bucket_name="centos7-web-aws"description="This is a CentOS7-based build that has been prepared as a web server in AWS."bucket_labels={
"build-version"="0.0.1",
"service"="aws"
}
build_labels={
"os"="centos7",
"version"="web"
}
}
sources=["source.amazon-ebs.centos7-web"]
}
Operating system and Environment details
All
Log Fragments and crash.log files
packer validate .
panic: can't use ElementIterator on unknown valuegoroutine 1 [running]:github.com/zclconf/go-cty/cty.Value.ElementIterator({{{0x69f8348, 0xc000dd1860}}, {0x535f020, 0xa692de0}}) /Users/runner/go/pkg/mod/github.com/zclconf/go-cty@v1.10.0/cty/value_ops.go:1118 +0xd8github.com/zclconf/go-cty/cty.Value.AsValueMap({{{0x69f8348, 0xc000dd1860}}, {0x535f020, 0xa692de0}}) /Users/runner/go/pkg/mod/github.com/zclconf/go-cty@v1.10.0/cty/value_ops.go:1324 +0xa5github.com/hashicorp/packer/hcl2template.(*Parser).decodeBuildConfig(0x53bb660, 0xc000de91e0, 0xc00037b040) /Users/runner/work/packer/packer/hcl2template/types.build.go:267 +0x1b14github.com/hashicorp/packer/hcl2template.(*Parser).parseConfig(0xc00037b040, 0xc0006ba160, 0xc00037b040) /Users/runner/work/packer/packer/hcl2template/parser.go:373 +0x1ebgithub.com/hashicorp/packer/hcl2template.(*PackerConfig).Initialize(0xc00037b040, {0x0}) /Users/runner/work/packer/packer/hcl2template/parser.go:326 +0x59agithub.com/hashicorp/packer/command.(*ValidateCommand).RunContext(0xc000810840, {0xc0001181a0, 0x1}, 0xc000a04000) /Users/runner/work/packer/packer/command/validate.go:59 +0x82github.com/hashicorp/packer/command.(*ValidateCommand).Run(0xc000810840, {0xc0001181a0, 0x1, 0x1}) /Users/runner/work/packer/packer/command/validate.go:25 +0xc5github.com/mitchellh/cli.(*CLI).Run(0xc000152140) /Users/runner/go/pkg/mod/github.com/mitchellh/cli@v1.1.2/cli.go:262 +0x5f8main.wrappedMain() /Users/runner/work/packer/packer/main.go:262 +0xaf2main.realMain() /Users/runner/work/packer/packer/main.go:49 +0xf3main.main() /Users/runner/work/packer/packer/main.go:35 +0x19!!!!!!!!!!!!!!!!!!!!!!!!!!! PACKER CRASH !!!!!!!!!!!!!!!!!!!!!!!!!!!!Packer crashed! This is always indicative of a bug within Packer.A crash log has been placed at "crash.log" relative to your currentworking directory. It would be immensely helpful if you could pleasereport the crash with Packer[1] so that we can fix this.[1]: https://github.com/hashicorp/packer/issues
The text was updated successfully, but these errors were encountered:
When we try to validate a build that contains references to
hcp_packer_image, the data is not fetched, and the value is therefore
unknown.
However, during the decoding phase for the build blocks, we attempt to
fetch the ancestry information for the current build, from the
information previously fetched from HCP.
Since we're validating, there's no way this is set, and attempting to
cast without checking causes Packer to crash on the conversion.
To avoid this, we only attempt this conversion if the value is known.
Closes#11870
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.
Community Note
Overview of the Issue
Running packer validate on an otherwise validate build template the contains an
hcp-packer-image
data source block causes Packer to crash. Running a build on the template does not result in the same error.This issue does not exist in v1.8.0 - main culprit for this issue is likely #11832
Reproduction Steps
Packer version
v1.8.2
Simplified Packer Template
Operating system and Environment details
All
Log Fragments and crash.log files
The text was updated successfully, but these errors were encountered: