hashicorp/terraform

locals { a = false ? [] : [{ a = null }, { a = [] }] } causes crash

Vlad1mir-D opened this issue · 2 comments

Terraform Version

Terraform v0.14.8

Terraform Configuration Files

locals { a = false ? [] : [{ a = null }, { a = [] }] }

Debug Output

https://gist.github.com/Vlad1mir-D/6040ed6cf341b1accaf29ccc80363d5c

Crash Output

https://gist.github.com/Vlad1mir-D/62cb918fa36054869c5c70c4101d9f94

Expected Behavior

No changes. Infrastructure is up-to-date.

This means that Terraform did not detect any differences between your
configuration and real physical resources that exist. As a result, no
actions need to be performed.

Actual Behavior

panic: inconsistent list element types (cty.Object(map[string]cty.Type{"a":cty.DynamicPseudoType}) then cty.Object(map[string]cty.Type{"a":cty.EmptyTuple}))

goroutine 50 [running]:
github.com/zclconf/go-cty/cty.ListVal(0xc000816d80, 0x2, 0x2, 0xc00064db10, 0x1, 0x1, 0x1)
        /go/pkg/mod/github.com/zclconf/go-cty@v1.8.0/cty/value_init.go:166 +0x5a8
github.com/zclconf/go-cty/cty/convert.conversionTupleToList.func2(0x2cea520, 0xc0007a75e0, 0x238cda0, 0xc0007a7600, 0x0, 0x0, 0x0, 0x2ca9a60, 0xc0007a76a0, 0x2cea3a0, ...)
        /go/pkg/mod/github.com/zclconf/go-cty@v1.8.0/cty/convert/conversion_collection.go:327 +0x794
github.com/zclconf/go-cty/cty/convert.getConversion.func1(0x2cea520, 0xc0007a75e0, 0x238cda0, 0xc0007a7600, 0x0, 0x0, 0x0, 0x23a6960, 0x3cab148, 0x2cea3a0, ...)
        /go/pkg/mod/github.com/zclconf/go-cty@v1.8.0/cty/convert/conversion.go:46 +0x433
github.com/zclconf/go-cty/cty/convert.retConversion.func1(0x2cea520, 0xc0007a75e0, 0x238cda0, 0xc0007a7600, 0x0, 0x0, 0x23a6960, 0x3cab140, 0xc00054b6b0, 0x3cab140)
        /go/pkg/mod/github.com/zclconf/go-cty@v1.8.0/cty/convert/conversion.go:188 +0x6b
github.com/hashicorp/hcl/v2/hclsyntax.(*ConditionalExpr).Value(0xc0001ac7e0, 0xc0007a7500, 0x0, 0xc0003cb800, 0x1, 0x1, 0x0, 0x0, 0x0)
        /go/pkg/mod/github.com/hashicorp/hcl/v2@v2.9.1/hclsyntax/expression.go:660 +0x16c2
github.com/hashicorp/terraform/lang.(*Scope).EvalExpr(0xc0000b9770, 0x2ce8ee0, 0xc0001ac7e0, 0x2cea3e0, 0x3dff7e0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
        /home/circleci/project/project/lang/eval.go:171 +0x1b7
github.com/hashicorp/terraform/terraform.(*BuiltinEvalContext).EvaluateExpr(0xc00054e4e0, 0x2ce8ee0, 0xc0001ac7e0, 0x2cea3e0, 0x3dff7e0, 0x0, 0x0, 0x0, 0x200000003, 0xc000546480, ...)
        /home/circleci/project/project/terraform/eval_context_builtin.go:287 +0xbb
github.com/hashicorp/terraform/terraform.(*NodeLocal).Execute(0xc00054a900, 0x2d26180, 0xc00054e4e0, 0x3dff704, 0x0, 0x0)
        /home/circleci/project/project/terraform/node_local.go:156 +0x71d
github.com/hashicorp/terraform/terraform.(*ContextGraphWalker).Execute(0xc0003a5ba0, 0x2d26180, 0xc00054e4e0, 0x7f6f91d3e358, 0xc00054a900, 0x0, 0x0, 0x0)
        /home/circleci/project/project/terraform/graph_walk_context.go:127 +0xbc
github.com/hashicorp/terraform/terraform.(*Graph).walk.func1(0x2692680, 0xc00054a900, 0x0, 0x0, 0x0)
        /home/circleci/project/project/terraform/graph.go:59 +0x962
github.com/hashicorp/terraform/dag.(*Walker).walkVertex(0xc00053cae0, 0x2692680, 0xc00054a900, 0xc000816940)
        /home/circleci/project/project/dag/walk.go:387 +0x375
created by github.com/hashicorp/terraform/dag.(*Walker).Update
        /home/circleci/project/project/dag/walk.go:309 +0x1246



!!!!!!!!!!!!!!!!!!!!!!!!!!! TERRAFORM CRASH !!!!!!!!!!!!!!!!!!!!!!!!!!!!

Terraform crashed! This is always indicative of a bug within Terraform.
A crash log has been placed at "crash.log" relative to your current
working directory. It would be immensely helpful if you could please
report the crash with Terraform[1] so that we can fix this.

When reporting bugs, please include your terraform version. That
information is available on the first line of crash.log. You can also
get it by running 'terraform --version' on the command line.

SECURITY WARNING: the "crash.log" file that was created may contain 
sensitive information that must be redacted before it is safe to share 
on the issue tracker.

[1]: https://github.com/hashicorp/terraform/issues

!!!!!!!!!!!!!!!!!!!!!!!!!!! TERRAFORM CRASH !!!!!!!!!!!!!!!!!!!!!!!!!!!!

Steps to Reproduce

  1. echo "locals { a = false ? [] : [{ a = null }, { a = [] }] }" > crash.tf
  2. terraform plan

Additional Context

References

Hi @Vlad1mir-D,

Thanks for filing the issue. This crash was fixed with a recent upgrade to the hcl and cty libraries in #28116, and will be included in the next major release.

Thanks!

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.