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: Call to function "alltrue" failed: panic in function implementation: interface #27297

Closed
jtalkington opened this issue Dec 16, 2020 · 3 comments
Labels
bug confirmed a Terraform Core team member has reproduced this issue

Comments

@jtalkington
Copy link

jtalkington commented Dec 16, 2020

Terraform Version

Terraform v0.14.2
+ provider registry.terraform.io/hashicorp/null v3.0.0

Terraform Configuration Files

terraform {
  required_version = "= 0.14.02"
}

variable "one" {
  type    = bool
  default = true
}

variable "two" {
  type    = bool
  default = true
}

resource "null_resource" "r" {
  count = (alltrue([var.one, var.two]) ? 1 : 0)

  provisioner "local-exec" {
    command = "echo Success"
  }
}

Debug Output

https://gist.github.com/jtalkington/e6b8327d00bbef578348e368a7ae596a

Crash Output

Adding the crash log here for searchability:

0xc000a3f938)
	github.com/zclconf/[email protected]/cty/function/function.go:291 +0x95
panic(0x3097ee0, 0xc00026d170)
	runtime/panic.go:969 +0x1b9
github.com/zclconf/go-cty/cty.Value.True(0x3858da0, 0xc000050451, 0x302b600,
0x493aaa0, 0x3858da0)
	github.com/zclconf/[email protected]/cty/value_ops.go:364 +0x136
github.com/zclconf/go-cty/cty.Value.False(...)
	github.com/zclconf/[email protected]/cty/value_ops.go:369
github.com/hashicorp/terraform/lang/funcs.glob..func7(0xc0007959a0, 0x1, 0x1,
0x3858da0, 0xc000050451, 0xc000975de0, 0x2f2e220, 0xc000795ba0, 0xc00026d0e0,
0x3858da0, ...)
	github.com/hashicorp/terraform/lang/funcs/collection.go:77 +0x252
github.com/zclconf/go-cty/cty/function.Function.Call(0xc00021e2a0,
0xc0007959a0, 0x1, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0)
	github.com/zclconf/[email protected]/cty/function/function.go:295 +0x51a
github.com/hashicorp/hcl/v2/hclsyntax.(*FunctionCallExpr).Value(0xc0005c2000,
0xc000795980, 0x2, 0xc00012e301, 0x3858da0, 0xc00005043f, 0xc000975d30, 0x2,
0x2)
	github.com/hashicorp/hcl/[email protected]/hclsyntax/expression.go:438 +0x10c5
github.com/hashicorp/hcl/v2/hclsyntax.(*ConditionalExpr).Value(0xc0000ecc40,
0xc000795980, 0x0, 0x0, 0xc000a413a8, 0x0, 0x0, 0x0, 0x0)
	github.com/hashicorp/hcl/[email protected]/hclsyntax/expression.go:596 +0x7fa
github.com/hashicorp/terraform/lang.(*Scope).EvalExpr(0xc000641180, 0x5696eb8,
0xc0004ba4b0, 0x3858da0, 0xc00005043f, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
	github.com/hashicorp/terraform/lang/eval.go:171 +0x1b7
github.com/hashicorp/terraform/terraform.(*BuiltinEvalContext).EvaluateExpr(0xc0000f6410,
0x5696eb8, 0xc0004ba4b0, 0x3858da0, 0xc00005043f, 0x0, 0x0,
0x17cb043cf8d42eb0, 0x7f169e8465b5ccac, 0x0, ...)
	github.com/hashicorp/terraform/terraform/eval_context_builtin.go:287 +0xbb
github.com/hashicorp/terraform/terraform.(*EvalValidateResource).validateCount(0xc000947bc0,
0x3894560, 0xc0000f6410, 0x5696eb8, 0xc0004ba4b0, 0x30, 0x50297d0, 0xcb522b8)
	github.com/hashicorp/terraform/terraform/eval_validate.go:487 +0x95
github.com/hashicorp/terraform/terraform.(*EvalValidateResource).Validate(0xc000a41bc0,
0x3894560, 0xc0000f6410, 0x0, 0x0)
	github.com/hashicorp/terraform/terraform/eval_validate.go:339 +0x16cc
github.com/hashicorp/terraform/terraform.(*NodeValidatableResource).Execute(0xc000592740,
0x3894560, 0xc0000f6410, 0x493ae04, 0x0, 0x0)
	github.com/hashicorp/terraform/terraform/node_resource_validate.go:55 +0x2f5
github.com/hashicorp/terraform/terraform.(*ContextGraphWalker).Execute(0xc000133ba0,
0x3894560, 0xc0000f6410, 0xccef7a8, 0xc000592740, 0x0, 0x0, 0x0)
	github.com/hashicorp/terraform/terraform/graph_walk_context.go:127 +0xbc
github.com/hashicorp/terraform/terraform.(*Graph).walk.func1(0x3358e60,
0xc000592740, 0x0, 0x0, 0x0)
	github.com/hashicorp/terraform/terraform/graph.go:59 +0x962
github.com/hashicorp/terraform/dag.(*Walker).walkVertex(0xc00032e180,
0x3358e60, 0xc000592740, 0xc000820bc0)
	github.com/hashicorp/terraform/dag/walk.go:387 +0x375
created by github.com/hashicorp/terraform/dag.(*Walker).Update
	github.com/hashicorp/terraform/dag/walk.go:309 +0x1246

Expected Behavior

Variables are evaluated properly.

Actual Behavior

Crash :(

Steps to Reproduce

  1. terraform init
  2. terraform apply

Additional Context

References

Probably the same as

@jtalkington jtalkington added bug new new issue not yet triaged labels Dec 16, 2020
@jtalkington
Copy link
Author

For those googling, this can be worked around by using the code below.

count = ((var.one && var.two) ? 1 : 0)

@mildwonkey mildwonkey added confirmed a Terraform Core team member has reproduced this issue and removed new new issue not yet triaged labels Dec 16, 2020
@mildwonkey
Copy link
Contributor

Hi @jtalkington , thanks for reporting this issue and I'm sorry you've experienced it!
I have confirmed that this issue existed in v0.14.2, but is fixed in the 0.14 branch, so that fix will be included in the next 0.14 release.
It looks like this is the PR which fixed this issue: #27240

I'm going to close this since there is a fix in place, thanks for opening it and including your workaround!

@ghost
Copy link

ghost commented Jan 16, 2021

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.

@ghost ghost locked as resolved and limited conversation to collaborators Jan 16, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug confirmed a Terraform Core team member has reproduced this issue
Projects
None yet
Development

No branches or pull requests

2 participants