Skip to content

setproduct panics #28984

@tbugfinder

Description

@tbugfinder

Terraform Version

]$ terraform -version
Terraform v1.0.0
on linux_amd64

and 
$ terraform version
Terraform v0.15.3
on linux_amd64


...

Terraform Configuration Files

locals {
  availability_zones_short = toset([substr(data.aws_availability_zones.available.names[0], -2, -1), substr(data.aws_availability_zones.available.names[1], -2, -1)])
  natgw_keys               = toset([for k in local.availability_zones_short : "natgw-${k}"])
  onprem_cidr_blocks = toset(["10.0.0.0/8", "172.16.0.0/12", "192.168.0.0/16" ])
}

data "aws_availability_zones" "available" {
  state = "available"
}

output "setproduct" {
  value = setproduct(local.natgw_keys, local.onprem_cidr_blocks)
}

Debug Output

[2021-06-18T16:35:43.369Z] $$$$$$ Validating the Terraform configuration files...
[2021-06-18T16:35:47.499Z]        
[2021-06-18T16:35:47.499Z]        Error: Error in function call
[2021-06-18T16:35:47.499Z]        
[2021-06-18T16:35:47.499Z]          on ../../../main.tf line 257, in resource "aws_route" "natgw_onprem":
[2021-06-18T16:35:47.499Z]         257:     for pair in setproduct(local.natgw_keys, local.onprem_cidr_blocks) : "${pair[0]}_${pair[1]}" => {
[2021-06-18T16:35:47.499Z]            ├────────────────
[2021-06-18T16:35:47.499Z]            │ local.natgw_keys is set of string with 2 elements
[2021-06-18T16:35:47.499Z]            │ local.onprem_cidr_blocks is set of string with 7 elements
[2021-06-18T16:35:47.499Z]        
[2021-06-18T16:35:47.499Z]        Call to function "setproduct" failed: panic in function implementation:
[2021-06-18T16:35:47.499Z]        runtime error: hash of unhashable type cty.ValueMarks
[2021-06-18T16:35:47.499Z]        goroutine 356 [running]:
[2021-06-18T16:35:47.499Z]        runtime/debug.Stack(0xc0022af3a8, 0x247fb40, 0xc002659d10)
[2021-06-18T16:35:47.499Z]        	/usr/local/go/src/runtime/debug/stack.go:24 +0x9f
[2021-06-18T16:35:47.499Z]        github.com/zclconf/go-cty/cty/function.errorForPanic(...)
[2021-06-18T16:35:47.499Z]        	/home/circleci/go/pkg/mod/github.com/zclconf/go-cty@v1.8.3/cty/function/error.go:44
[2021-06-18T16:35:47.499Z]        github.com/zclconf/go-cty/cty/function.Function.Call.func1(0xc0022afb60,
[2021-06-18T16:35:47.499Z]        0xc0022afb80)
[2021-06-18T16:35:47.499Z]        	/home/circleci/go/pkg/mod/github.com/zclconf/go-cty@v1.8.3/cty/function/function.go:291
[2021-06-18T16:35:47.499Z]        +0x93
[2021-06-18T16:35:47.499Z]        panic(0x247fb40, 0xc002659d10)
[2021-06-18T16:35:47.499Z]        	/usr/local/go/src/runtime/panic.go:965 +0x1b9
[2021-06-18T16:35:47.499Z]        github.com/zclconf/go-cty/cty.Value.Mark(0x2cb97b0, 0xc002659cf0, 0x24341a0,
[2021-06-18T16:35:47.499Z]        0x3dafde0, 0x252f520, 0x0, 0x24341a0, 0x3dafde0, 0x0, 0xc00073ee10)
[2021-06-18T16:35:47.499Z]        	/home/circleci/go/pkg/mod/github.com/zclconf/go-cty@v1.8.3/cty/marks.go:208
[2021-06-18T16:35:47.499Z]        +0x1dc
[2021-06-18T16:35:47.499Z]        github.com/zclconf/go-cty/cty/function/stdlib.glob..func33(0xc0026fbdc0, 0x2,
[2021-06-18T16:35:47.499Z]        0x2, 0x2cb97b0, 0xc002659cf0, 0xc002659cf0, 0x0, 0x0, 0x3db02e8, 0x40dc01,
[2021-06-18T16:35:47.499Z]        ...)
[2021-06-18T16:35:47.499Z]        	/home/circleci/go/pkg/mod/github.com/zclconf/go-cty@v1.8.3/cty/function/stdlib/collection.go:948
[2021-06-18T16:35:47.499Z]        +0x119a
[2021-06-18T16:35:47.499Z]        github.com/zclconf/go-cty/cty/function.Function.Call(0xc00004dd10,
[2021-06-18T16:35:47.499Z]        0xc0026fbdc0, 0x2, 0x2, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0)
[2021-06-18T16:35:47.499Z]        	/home/circleci/go/pkg/mod/github.com/zclconf/go-cty@v1.8.3/cty/function/function.go:295
[2021-06-18T16:35:47.499Z]        +0x4a7
[2021-06-18T16:35:47.499Z]        github.com/hashicorp/hcl/v2/hclsyntax.(*FunctionCallExpr).Value(0xc0003a3a40,
[2021-06-18T16:35:47.499Z]        0xc00288e0c0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0)
[2021-06-18T16:35:47.499Z]        	/home/circleci/go/pkg/mod/github.com/hashicorp/hcl/v2@v2.10.0/hclsyntax/expression.go:442
[2021-06-18T16:35:47.499Z]        +0xff6
[2021-06-18T16:35:47.499Z]        github.com/hashicorp/hcl/v2/hclsyntax.(*ForExpr).Value(0xc00089de00,
[2021-06-18T16:35:47.499Z]        0xc00288e0c0, 0x0, 0xc0022b1500, 0x1, 0x1, 0x0, 0x0, 0x0)
[2021-06-18T16:35:47.500Z]        	/home/circleci/go/pkg/mod/github.com/hashicorp/hcl/v2@v2.10.0/hclsyntax/expression.go:993
[2021-06-18T16:35:47.500Z]        +0x59
[2021-06-18T16:35:47.500Z]        github.com/hashicorp/terraform/internal/terraform.evaluateForEachExpressionValue(0x7fa7fb02b9d8,
[2021-06-18T16:35:47.500Z]        0xc00089de00, 0x2cf0800, 0xc0007dc1c0, 0x1, 0x397377612d746e69,
[2021-06-18T16:35:47.500Z]        0x3835333036353138, 0x7365742d77662d6f, 0x6c75616665642d74,
[2021-06-18T16:35:47.500Z]        0x2e6c61636f6c2e74, ...)
[2021-06-18T16:35:47.500Z]        	/home/circleci/project/project/internal/terraform/eval_for_each.go:59 +0x33a
[2021-06-18T16:35:47.500Z]        github.com/hashicorp/terraform/internal/terraform.validateForEach(0x2cf0800,
[2021-06-18T16:35:47.500Z]        0xc0007dc1c0, 0x7fa7fb02b9d8, 0xc00089de00, 0x1, 0x1, 0x0)
[2021-06-18T16:35:47.500Z]        	/home/circleci/project/project/internal/terraform/node_resource_validate.go:461
[2021-06-18T16:35:47.500Z]        +0x6c
[2021-06-18T16:35:47.500Z]        github.com/hashicorp/terraform/internal/terraform.(*NodeValidatableResource).validateResource(0xc00070c0f8,
[2021-06-18T16:35:47.500Z]        0x2cf0800, 0xc0007dc1c0, 0xc0000cbc50, 0x405c88, 0xc000e76058)
[2021-06-18T16:35:47.500Z]        	/home/circleci/project/project/internal/terraform/node_resource_validate.go:302
[2021-06-18T16:35:47.500Z]        +0x1d6a
[2021-06-18T16:35:47.500Z]        github.com/hashicorp/terraform/internal/terraform.(*NodeValidatableResource).Execute(0xc00070c0f8,
[2021-06-18T16:35:47.500Z]        0x2cf0800, 0xc0007dc1c0, 0xc06104, 0xc0000cbce8, 0x40bb05, 0x24aa5e0)
[2021-06-18T16:35:47.500Z]        	/home/circleci/project/project/internal/terraform/node_resource_validate.go:41
[2021-06-18T16:35:47.500Z]        +0x5a
[2021-06-18T16:35:47.500Z]        github.com/hashicorp/terraform/internal/terraform.(*ContextGraphWalker).Execute(0xc0009d4680,
[2021-06-18T16:35:47.500Z]        0x2cf0800, 0xc0007dc1c0, 0x7fa7fb3c3420, 0xc00070c0f8, 0x0, 0x0, 0x0)
[2021-06-18T16:35:47.500Z]        	/home/circleci/project/project/internal/terraform/graph_walk_context.go:129
[2021-06-18T16:35:47.500Z]        +0xbf
[2021-06-18T16:35:47.500Z]        github.com/hashicorp/terraform/internal/terraform.(*Graph).walk.func1(0x27ba020,
[2021-06-18T16:35:47.500Z]        0xc00070c0f8, 0x0, 0x0, 0x0)
[2021-06-18T16:35:47.500Z]        	/home/circleci/project/project/internal/terraform/graph.go:59 +0xbd3
[2021-06-18T16:35:47.500Z]        github.com/hashicorp/terraform/internal/dag.(*Walker).walkVertex(0xc0000ff7a0,
[2021-06-18T16:35:47.500Z]        0x27ba020, 0xc00070c0f8, 0xc000e57080)
[2021-06-18T16:35:47.500Z]        	/home/circleci/project/project/internal/dag/walk.go:381 +0x288
[2021-06-18T16:35:47.500Z]        created by github.com/hashicorp/terraform/internal/dag.(*Walker).Update
[2021-06-18T16:35:47.500Z]        	/home/circleci/project/project/internal/dag/walk.go:304 +0x1246
[2021-06-18T16:35:47.500Z]        .
[2021-06-18T16:35:47.500Z]        
[2021-06-18T16:35:47.500Z]        Error: Error in function call
[2021-06-18T16:35:47.500Z]        

Crash Output

Expected Behavior

It execute successfully like 0.14.11 does.

Actual Behavior

Steps to Reproduce

Additional Context

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugconfirmeda Terraform Core team member has reproduced this issuecrashexplaineda Terraform Core team member has described the root cause of this issue in codefunctionsupstream

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions