Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Panic when using setproduct() with certain locals in v1.4.1 (works with 1.4.0) #32853

Closed
lra opened this issue Mar 15, 2023 · 4 comments
Closed
Labels
bug new new issue not yet triaged upstream v1.4 Issues (primarily bugs) reported against v1.4 releases

Comments

@lra
Copy link

lra commented Mar 15, 2023

Terraform Version

Terraform v1.4.1
on darwin_arm64
+ provider registry.terraform.io/hashicorp/azurerm v3.47.0

Terraform Configuration Files

locals {
  redis_aks_rules = setproduct(
    values(azurerm_redis_cache.this),
    concat(
      [azurerm_public_ip.cluster_egress_pip],
      azurerm_public_ip.cluster_egress_pips[*]
    )
  )

  redis_instances = {
    "apim-deployment" = {
      redis_version       = 4
      minimum_tls_version = "1.0"
      service             = "exp"
    }
    "article" = {}
    "bes" = {
      redis_version       = 4
      minimum_tls_version = "1.0"
    }
  }
}

resource "azurerm_redis_cache" "this" {
  for_each            = local.redis_instances
  name                = each.key
  location            = "westus"
  resource_group_name = "blah"
  sku_name            = "Basic"
  capacity            = 0
  family              = "C"
  redis_version       = lookup(each.value, "redis_version", 6)
  enable_non_ssl_port = false
  minimum_tls_version = lookup(each.value, "minimum_tls_version", "1.2")
}

resource "azurerm_public_ip" "cluster_egress_pip" {
  name                = "test"
  resource_group_name = "blah"
  location            = "westus"
  allocation_method   = "Static"
  sku                 = "Standard"
}

resource "azurerm_public_ip" "cluster_egress_pips" {
  count               = 10
  name                = "test-${count.index}"
  resource_group_name = "blah"
  location            = "westus"
  allocation_method   = "Static"
  sku                 = "Standard"
}

Debug Output

https://gist.github.com/lra/803b2619d5b04131d72e2ef019ba9df5

Expected Behavior

$ terraform validate
Success! The configuration is valid.

Actual Behavior

$ terraform validate
╷
│ Error: Error in function call
│ 
│   on test.tf line 2, in locals:
│    2:   redis_aks_rules = setproduct(
│    3:     values(azurerm_redis_cache.this),
│    4:     concat(
│    5:       [azurerm_public_ip.cluster_egress_pip],
│    6:       azurerm_public_ip.cluster_egress_pips[*]
│    7:     )
│    8:   )
│     ├────────────────
│     │ while calling setproduct(sets...)
│ 
│ Call to function "setproduct" failed: panic in function implementation: not a collection type

Steps to Reproduce

  1. terraform init
  2. terraform validate

Additional Context

It's working in v1.3.9 and in v1.4.0

References

No response

@lra lra added bug new new issue not yet triaged labels Mar 15, 2023
@lra lra changed the title Panic when using setproduct() in v1.4.1 Panic when using setproduct() with certain locals in v1.4.1 Mar 15, 2023
@lra lra changed the title Panic when using setproduct() with certain locals in v1.4.1 Panic when using setproduct() with certain locals in v1.4.1 (works with 1.4.0) Mar 15, 2023
@apparentlymart apparentlymart added the v1.4 Issues (primarily bugs) reported against v1.4 releases label Mar 15, 2023
@mbevc1
Copy link

mbevc1 commented Mar 15, 2023

Noticed same here as well:

on .terraform/modules/vpc-peering/locals.tf line 28, in locals:
│   28:     for pair in setproduct(local.this_rts_ids_hack, local.this_dest_cidrs) : {
│     ├────────────────
│     │ while calling setproduct(sets...)
│     │ local.this_dest_cidrs is a set of dynamic
│ 
│ Call to function "setproduct" failed: panic in function implementation: not
│ a collection type
│ goroutine 6429 [running]:
│ runtime/debug.Stack()
│ 	/usr/local/go/src/runtime/debug/stack.go:24 +0x65
│ github.com/zclconf/go-cty/cty/function.errorForPanic(...)
│ 	/home/circleci/go/pkg/mod/github.com/zclconf/[email protected]/cty/function/error.go:44
│ github.com/zclconf/go-cty/cty/function.Function.Call.func2()
│ 	/home/circleci/go/pkg/mod/github.com/zclconf/[email protected]/cty/function/function.go:323
│ +0x9f
│ panic({0x2335100, 0xc007134e50})
│ 	/usr/local/go/src/runtime/panic.go:884 +0x212
│ github.com/zclconf/go-cty/cty.Type.ElementType({{0x2d881f8?, 0x41d3d58?}})
│ 	/home/circleci/go/pkg/mod/github.com/zclconf/[email protected]/cty/collection.go:25
│ +0x78
│ github.com/zclconf/go-cty/cty/function/stdlib.glob..func33({0xc00715f680,
│ 0x2, 0x2342ae0?}, {{0x2d881f8?, 0x41d3d58?}})
│ 	/home/circleci/go/pkg/mod/github.com/zclconf/[email protected]/cty/function/stdlib/collection.go:982
│ +0x93
│ github.com/zclconf/go-cty/cty/function.Function.Call({0x2d882d8?},
│ {0xc00715f680?, 0x2, 0x2})
│ 	/home/circleci/go/pkg/mod/github.com/zclconf/[email protected]/cty/function/function.go:327
│ +0x314
│ github.com/hashicorp/hcl/v2/hclsyntax.(*FunctionCallExpr).Value(0xc0010ea690,
│ 0xc00711b338)
│ 	/home/circleci/go/pkg/mod/github.com/hashicorp/hcl/[email protected]/hclsyntax/expression.go:456
│ +0x1c85
│ github.com/hashicorp/hcl/v2/hclsyntax.(*ForExpr).Value(0xc000cf0c80,
│ 0xc00711b338)
│ 	/home/circleci/go/pkg/mod/github.com/hashicorp/hcl/[email protected]/hclsyntax/expression.go:1215
│ +0x4a
│ github.com/hashicorp/terraform/internal/lang.(*Scope).EvalExpr(0xc00711da40,
│ {0x7f47b9e6c5d8?, 0xc000cf0c80}, {{0x2d881f8?, 0x41d3d58?}})
│ 	/home/circleci/project/project/internal/lang/eval.go:171 +0x148
│ github.com/hashicorp/terraform/internal/terraform.(*BuiltinEvalContext).EvaluateExpr(0x7f47b9e6c5d8?,
│ {0x7f47b9e6c5d8, 0xc000cf0c80}, {{0x2d881f8?, 0x41d3d58?}}, {0x0?, 0x0?})
│ 	/home/circleci/project/project/internal/terraform/eval_context_builtin.go:283
│ +0xc5
│ github.com/hashicorp/terraform/internal/terraform.(*NodeLocal).Execute(0x0?,
│ {0x2da0158, 0xc002686460}, 0x80?)
│ 	/home/circleci/project/project/internal/terraform/node_local.go:154 +0x5aa
│ github.com/hashicorp/terraform/internal/terraform.(*ContextGraphWalker).Execute(0xc0020cb860,
│ {0x2da0158, 0xc002686460}, {0x7f47b9c3dcc0, 0xc006494390})
│ 	/home/circleci/project/project/internal/terraform/graph_walk_context.go:136
│ +0xc2
│ github.com/hashicorp/terraform/internal/terraform.(*Graph).walk.func1({0x255ee80,
│ 0xc006494390})
│ 	/home/circleci/project/project/internal/terraform/graph.go:75 +0x315
│ github.com/hashicorp/terraform/internal/dag.(*Walker).walkVertex(0xc0067b3e60,
│ {0x255ee80, 0xc006494390}, 0xc006492840)
│ 	/home/circleci/project/project/internal/dag/walk.go:381 +0x2f6
│ created by github.com/hashicorp/terraform/internal/dag.(*Walker).Update
│ 	/home/circleci/project/project/internal/dag/walk.go:304 +0xf65
│ .

@Riinkesh
Copy link

Riinkesh commented Mar 16, 2023

I see the same issue with setproduct function in TF version 1.4.1

Call to function "setproduct" failed: panic in function implementation: not a collection type goroutine 804 [running]: runtime/debug.Stack() /usr/local/go/src/runtime/debug/stack.go:24 +0x65 github.com/zclconf/go-cty/cty/function.errorForPanic(...) /home/circleci/go/pkg/mod/github.com/zclconf/[email protected]/cty/function/error.go:44 github.com/zclconf/go-cty/cty/function.Function.Call.func2() /home/circleci/go/pkg/mod/github.com/zclconf/[email protected]/cty/function/function.go:323 +0x9f panic({0x2335100, 0xc001f7e5d0}) /usr/local/go/src/runtime/panic.go:884 +0x212 github.com/zclconf/go-cty/cty.Type.ElementType({{0x2d881f8?, 0x41d3d58?}}) /home/circleci/go/pkg/mod/github.com/zclconf/[email protected]/cty/collection.go:25 +0x78 github.com/zclconf/go-cty/cty/function/stdlib.glob..func33({0xc004177fc0, 0x2, 0x2342ae0?}, {{0x2d881f8?, 0x41d3d58?}}) /home/circleci/go/pkg/mod/github.com/zclconf/[email protected]/cty/function/stdlib/collection.go:982 +0x93 github.com/zclconf/go-cty/cty/function.Function.Call({0x2d88230?}, {0xc004177fc0?, 0x2, 0x2}) /home/circleci/go/pkg/mod/github.com/zclconf/[email protected]/cty/function/function.go:327 +0x314 github.com/hashicorp/hcl/v2/hclsyntax.(*FunctionCallExpr).Value(0xc0004f1860, 0xc00417e0d8) /home/circleci/go/pkg/mod/github.com/hashicorp/hcl/[email protected]/hclsyntax/expression.go:456 +0x1c85 github.com/hashicorp/terraform/internal/lang.(*Scope).EvalExpr(0xc00414af60, {0x2d86f98?, 0xc0004f1860}, {{0x2d881f8?, 0x41d3d58?}}) /home/circleci/project/project/internal/lang/eval.go:171 +0x148 github.com/hashicorp/terraform/internal/terraform.(*BuiltinEvalContext).EvaluateExpr(0x2d86f98?, {0x2d86f98, 0xc0004f1860}, {{0x2d881f8?, 0x41d3d58?}}, {0x0?, 0x0?}) /home/circleci/project/project/internal/terraform/eval_context_builtin.go:283 +0xc5 github.com/hashicorp/terraform/internal/terraform.(*NodeLocal).Execute(0x0?, {0x2da0158, 0xc000deafc0}, 0xe0?) /home/circleci/project/project/internal/terraform/node_local.go:154 +0x5aa github.com/hashicorp/terraform/internal/terraform.(*ContextGraphWalker).Execute(0xc002920780, {0x2da0158, 0xc000deafc0}, {0x7f23d0cf0fb8, 0xc000dafec0}) /home/circleci/project/project/internal/terraform/graph_walk_context.go:136 +0xc2 github.com/hashicorp/terraform/internal/terraform.(*Graph).walk.func1({0x255ee80, 0xc000dafec0}) /home/circleci/project/project/internal/terraform/graph.go:75 +0x315 github.com/hashicorp/terraform/internal/dag.(*Walker).walkVertex(0xc003f5c480, {0x255ee80, 0xc000dafec0}, 0xc003f5fdc0) /home/circleci/project/project/internal/dag/walk.go:381 +0x2f6 created by github.com/hashicorp/terraform/internal/dag.(*Walker).Update /home/circleci/project/project/internal/dag/walk.go:304 +0xf65 .

stigok added a commit to nrkno/github-workflow-terraform-config that referenced this issue Mar 16, 2023
A [bug in Terraform v1.4.1][bug] breaks some usage of `setproduct`. Temporarily
defaulting to v1.4.0 instead.

[bug]: hashicorp/terraform#32853
stigok added a commit to nrkno/github-workflow-terraform-config that referenced this issue Mar 16, 2023
A [bug in Terraform v1.4.1][bug] breaks some usage of `setproduct`. Temporarily
defaulting to v1.4.0 instead.

[bug]: hashicorp/terraform#32853
stigok added a commit to nrkno/github-workflow-terraform-config that referenced this issue Mar 16, 2023
A [bug in Terraform v1.4.1][bug] breaks some usage of `setproduct`. Temporarily
defaulting to v1.4.0 instead.

[bug]: hashicorp/terraform#32853
@jbardin
Copy link
Member

jbardin commented Mar 16, 2023

Closed via #32860

@github-actions
Copy link

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 16, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug new new issue not yet triaged upstream v1.4 Issues (primarily bugs) reported against v1.4 releases
Projects
None yet
Development

No branches or pull requests

5 participants