hashicorp / terraform

Terraform enables you to safely and predictably create, change, and improve infrastructure. It is a source-available tool that codifies APIs into declarative configuration files that can be shared amongst team members, treated as code, edited, reviewed, and versioned.
https://www.terraform.io/
Other
42.35k stars 9.49k forks source link

Terraform crash while using terraform validate #34141

Closed gce1estine closed 10 months ago

gce1estine commented 11 months ago

Terraform Version

terraform 1.6.0

Terraform Configuration Files

  required_version = "~> 1.6.0"
  required_providers {
    aws = {
      source  = "hashicorp/aws"
      version = "~> 5.0"
    }
  }

Debug Output

!!!!!!!!!!!!!!!!!!!!!!!!!!! TERRAFORM CRASH !!!!!!!!!!!!!!!!!!!!!!!!!!!!
value is marked, so must be unmarked first
goroutine 1502 [running]:
runtime/debug.Stack()
    /opt/hostedtoolcache/go/1.21.1/x64/src/runtime/debug/stack.go:24 +0x5e
runtime/debug.PrintStack()
    /opt/hostedtoolcache/go/1.21.1/x64/src/runtime/debug/stack.go:16 +0x13
github.com/hashicorp/terraform/internal/logging.PanicHandler()
    /home/runner/work/terraform/terraform/internal/logging/panic.go:58 +0x13b
panic({0x2b92ec0?, 0x38c4c30?})
    /opt/hostedtoolcache/go/1.21.1/x64/src/runtime/panic.go:920 +0x270
github.com/zclconf/go-cty/cty.Value.assertUnmarked(...)
    /home/runner/go/pkg/mod/github.com/zclconf/go-cty@v1.14.0/cty/marks.go:141
github.com/zclconf/go-cty/cty.Value.AsString({{{0x3902720?, 0xc000144bd1?}}, {0x2e1de40?, 0xc0036c7c80?}})
    /home/runner/go/pkg/mod/github.com/zclconf/go-cty@v1.14.0/cty/value_ops.go:1385 +0x47
github.com/zclconf/go-cty/cty.Value.Range({{{0x3902720?, 0xc000144bd1?}}, {0x2e1de40?, 0xc0036c7c80?}})
    /home/runner/go/pkg/mod/github.com/zclconf/go-cty@v1.14.0/cty/value_range.go:53 +0x285
github.com/hashicorp/hcl/v2/hclsyntax.(*ConditionalExpr).Value(0xc000976230, 0xc0036c7c68)
    /home/runner/go/pkg/mod/github.com/hashicorp/hcl/v2@v2.18.0/hclsyntax/expression.go:746 +0xd6a
github.com/hashicorp/terraform/internal/lang.(*Scope).EvalExpr(0xc00371b290, {0x3902df8?, 0xc000976230}, {{0x3902f48?, 0x5130520?}})
    /home/runner/work/terraform/terraform/internal/lang/eval.go:175 +0x1bd
github.com/hashicorp/terraform/internal/terraform.(*BuiltinEvalContext).EvaluateExpr(0x5c?, {0x3902df8, 0xc000976230}, {{0x3902f48?, 0x5130520?}}, {0x0?, 0x0?})
    /home/runner/work/terraform/terraform/internal/terraform/eval_context_builtin.go:289 +0xab
github.com/hashicorp/terraform/internal/terraform.(*NodeLocal).Execute(0x7fcaf13b26d8?, {0x391fb60, 0xc0023ee2a0}, 0xd0?)
    /home/runner/work/terraform/terraform/internal/terraform/node_local.go:158 +0x592
github.com/hashicorp/terraform/internal/terraform.(*ContextGraphWalker).Execute(0xc004487320, {0x391fb60, 0xc0023ee2a0}, {0x7fcaf13cb418, 0xc005e04f60})
    /home/runner/work/terraform/terraform/internal/terraform/graph_walk_context.go:143 +0xbe
github.com/hashicorp/terraform/internal/terraform.(*Graph).walk.func1({0x2f5[93](https://gitlab.e-nrj.mysk5.com/run/e-nrj/infrastructure/-/jobs/36972#L93)a0, 0xc005e04f60})
    /home/runner/work/terraform/terraform/internal/terraform/graph.go:78 +0x375
github.com/hashicorp/terraform/internal/dag.(*Walker).walkVertex(0xc00012b800, {0x2f593a0, 0xc005e04f60}, 0xc002326c40)
    /home/runner/work/terraform/terraform/internal/dag/walk.go:384 +0x2e5
created by github.com/hashicorp/terraform/internal/dag.(*Walker).Update in goroutine 481
    /home/runner/work/terraform/terraform/internal/dag/walk.go:307 +0xde8
Cleaning up project directory and file based variables

Expected Behavior

no crash and configuration validation

Actual Behavior

crash as stated in the debug output

Steps to Reproduce

terraform init terraform validate

Additional Context

commands are issued by a selfmanaged gitlab-runner using 16.2.0 version of the runner in Kubernetes

References

No response

apparentlymart commented 11 months ago

Hi @gce1estine! Thanks for reporting this.

A similar error was reported previously and has been fixed in one of the later patch releases in the v1.6 series. Could you try upgrading to the latest available patch release to see if the problem still occurs for you?

Thanks again!

gce1estine commented 10 months ago

closing the issue since it has been fixed in a new version.

github-actions[bot] commented 9 months ago

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.