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 with nested splat on scalar value inside splat on list #36284

Open
apparentlymart opened this issue Jan 7, 2025 · 1 comment
Open

Panic with nested splat on scalar value inside splat on list #36284

apparentlymart opened this issue Jan 7, 2025 · 1 comment
Labels
bug new new issue not yet triaged

Comments

@apparentlymart
Copy link
Contributor

Terraform Version

Terraform v1.10.3
on linux_amd64

Terraform Configuration Files

locals {
  foo = tolist([
    {
      a = "a"
      b = null
    },
    {
      a = null
      b = "b"
    },
  ])
}

output "example" {
  value = local.foo[*].b[*]
}

Debug Output

2025-01-07T13:19:44.555-0800 [INFO]  Terraform version: 1.10.3
2025-01-07T13:19:44.555-0800 [DEBUG] using github.com/hashicorp/go-tfe v1.70.0
2025-01-07T13:19:44.555-0800 [DEBUG] using github.com/hashicorp/hcl/v2 v2.23.0
2025-01-07T13:19:44.555-0800 [DEBUG] using github.com/hashicorp/terraform-svchost v0.1.1
2025-01-07T13:19:44.555-0800 [DEBUG] using github.com/zclconf/go-cty v1.15.1-0.20241111215639-63279be090d7
2025-01-07T13:19:44.555-0800 [INFO]  Go runtime version: go1.23.3
2025-01-07T13:19:44.555-0800 [INFO]  CLI args: []string{"./terraform", "plan"}
2025-01-07T13:19:44.555-0800 [TRACE] Stdout is a terminal of width 180
2025-01-07T13:19:44.555-0800 [TRACE] Stderr is a terminal of width 180
2025-01-07T13:19:44.555-0800 [TRACE] Stdin is a terminal
2025-01-07T13:19:44.555-0800 [DEBUG] Attempting to open CLI config file: /home/mart/.terraformrc
2025-01-07T13:19:44.555-0800 [DEBUG] File doesn't exist, but doesn't need to. Ignoring.
2025-01-07T13:19:44.555-0800 [DEBUG] ignoring non-existing provider search directory terraform.d/plugins
2025-01-07T13:19:44.556-0800 [INFO]  CLI command args: []string{"plan"}
2025-01-07T13:19:44.556-0800 [TRACE] Meta.Backend: no config given or present on disk, so returning nil config
2025-01-07T13:19:44.556-0800 [TRACE] Meta.Backend: backend has not previously been initialized in this working directory
2025-01-07T13:19:44.556-0800 [TRACE] Meta.Backend: using default local state only (no backend configuration, and no existing initialized backend)
2025-01-07T13:19:44.556-0800 [TRACE] Meta.Backend: instantiated backend of type <nil>
2025-01-07T13:19:44.556-0800 [DEBUG] checking for provisioner in "."
2025-01-07T13:19:44.556-0800 [DEBUG] checking for provisioner in "/tmp/terraform-splat-crash"
2025-01-07T13:19:44.556-0800 [TRACE] Meta.Backend: backend <nil> does not support operations, so wrapping it in a local backend
2025-01-07T13:19:44.556-0800 [INFO]  backend/local: starting Plan operation
2025-01-07T13:19:44.556-0800 [TRACE] backend/local: requesting state manager for workspace "default"
2025-01-07T13:19:44.556-0800 [TRACE] backend/local: state manager for workspace "default" will:
 - read initial snapshot from terraform.tfstate
 - write new snapshots to terraform.tfstate
 - create any backup at terraform.tfstate.backup
2025-01-07T13:19:44.556-0800 [TRACE] backend/local: requesting state lock for workspace "default"
2025-01-07T13:19:44.556-0800 [TRACE] statemgr.Filesystem: preparing to manage state snapshots at terraform.tfstate
2025-01-07T13:19:44.556-0800 [TRACE] statemgr.Filesystem: no previously-stored snapshot exists
2025-01-07T13:19:44.556-0800 [TRACE] statemgr.Filesystem: locking terraform.tfstate using fcntl flock
2025-01-07T13:19:44.557-0800 [TRACE] statemgr.Filesystem: writing lock metadata to .terraform.tfstate.lock.info
2025-01-07T13:19:44.557-0800 [TRACE] backend/local: reading remote state for workspace "default"
2025-01-07T13:19:44.557-0800 [TRACE] statemgr.Filesystem: reading latest snapshot from terraform.tfstate
2025-01-07T13:19:44.557-0800 [TRACE] statemgr.Filesystem: snapshot file has nil snapshot, but that's okay
2025-01-07T13:19:44.557-0800 [TRACE] statemgr.Filesystem: read nil snapshot
2025-01-07T13:19:44.557-0800 [TRACE] backend/local: populating backendrun.LocalRun for current working directory
2025-01-07T13:19:44.557-0800 [TRACE] terraform.NewContext: starting
2025-01-07T13:19:44.557-0800 [TRACE] terraform.NewContext: complete
2025-01-07T13:19:44.557-0800 [TRACE] backend/local: requesting interactive input, if necessary
2025-01-07T13:19:44.557-0800 [TRACE] Context.Input: Prompting for provider arguments
2025-01-07T13:19:44.557-0800 [TRACE] backend/local: running validation operation
2025-01-07T13:19:44.557-0800 [DEBUG] Building and walking validate graph
2025-01-07T13:19:44.557-0800 [TRACE] building graph for walkValidate
2025-01-07T13:19:44.557-0800 [TRACE] Executing graph transform *terraform.ConfigTransformer
2025-01-07T13:19:44.557-0800 [TRACE] ConfigTransformer: Starting for path:
2025-01-07T13:19:44.557-0800 [TRACE] Completed graph transform *terraform.ConfigTransformer (no changes)
2025-01-07T13:19:44.557-0800 [TRACE] Executing graph transform *terraform.RootVariableTransformer
2025-01-07T13:19:44.557-0800 [TRACE] Completed graph transform *terraform.RootVariableTransformer (no changes)
2025-01-07T13:19:44.557-0800 [TRACE] Executing graph transform *terraform.ModuleVariableTransformer
2025-01-07T13:19:44.557-0800 [TRACE] Completed graph transform *terraform.ModuleVariableTransformer (no changes)
2025-01-07T13:19:44.557-0800 [TRACE] Executing graph transform *terraform.variableValidationTransformer
2025-01-07T13:19:44.557-0800 [TRACE] variableValidationTransformer: adding validation nodes for any existing variable evaluation nodes
2025-01-07T13:19:44.557-0800 [TRACE] Completed graph transform *terraform.variableValidationTransformer (no changes)
2025-01-07T13:19:44.557-0800 [TRACE] Executing graph transform *terraform.LocalTransformer
2025-01-07T13:19:44.557-0800 [TRACE] Completed graph transform *terraform.LocalTransformer with new graph:
  local.foo (expand) - *terraform.nodeExpandLocal
  ------
2025-01-07T13:19:44.557-0800 [TRACE] Executing graph transform *terraform.OutputTransformer
2025-01-07T13:19:44.557-0800 [TRACE] OutputTransformer: adding example as *terraform.nodeExpandOutput
2025-01-07T13:19:44.557-0800 [TRACE] Completed graph transform *terraform.OutputTransformer with new graph:
  local.foo (expand) - *terraform.nodeExpandLocal
  output.example (expand) - *terraform.nodeExpandOutput
  ------
2025-01-07T13:19:44.557-0800 [TRACE] Executing graph transform *terraform.checkTransformer
2025-01-07T13:19:44.557-0800 [TRACE] Completed graph transform *terraform.checkTransformer (no changes)
2025-01-07T13:19:44.557-0800 [TRACE] Executing graph transform *terraform.OrphanResourceInstanceTransformer
2025-01-07T13:19:44.557-0800 [TRACE] Completed graph transform *terraform.OrphanResourceInstanceTransformer (no changes)
2025-01-07T13:19:44.557-0800 [TRACE] Executing graph transform *terraform.StateTransformer
2025-01-07T13:19:44.557-0800 [TRACE] StateTransformer: pointless no-op call, creating no nodes at all
2025-01-07T13:19:44.557-0800 [TRACE] Completed graph transform *terraform.StateTransformer (no changes)
2025-01-07T13:19:44.557-0800 [TRACE] Executing graph transform *terraform.AttachStateTransformer
2025-01-07T13:19:44.557-0800 [TRACE] Completed graph transform *terraform.AttachStateTransformer (no changes)
2025-01-07T13:19:44.557-0800 [TRACE] Executing graph transform *terraform.OrphanOutputTransformer
2025-01-07T13:19:44.557-0800 [TRACE] Completed graph transform *terraform.OrphanOutputTransformer (no changes)
2025-01-07T13:19:44.557-0800 [TRACE] Executing graph transform *terraform.AttachResourceConfigTransformer
2025-01-07T13:19:44.557-0800 [TRACE] Completed graph transform *terraform.AttachResourceConfigTransformer (no changes)
2025-01-07T13:19:44.557-0800 [TRACE] Executing graph transform *terraform.graphTransformerMulti
2025-01-07T13:19:44.557-0800 [TRACE] (graphTransformerMulti) Executing graph transform *terraform.externalProviderTransformer
2025-01-07T13:19:44.557-0800 [TRACE] (graphTransformerMulti) Completed graph transform *terraform.externalProviderTransformer with new graph:
  local.foo (expand) - *terraform.nodeExpandLocal
  output.example (expand) - *terraform.nodeExpandOutput
  ------
2025-01-07T13:19:44.557-0800 [TRACE] (graphTransformerMulti) Executing graph transform *terraform.ProviderConfigTransformer
2025-01-07T13:19:44.557-0800 [TRACE] (graphTransformerMulti) Completed graph transform *terraform.ProviderConfigTransformer (no changes)
2025-01-07T13:19:44.557-0800 [TRACE] (graphTransformerMulti) Executing graph transform *terraform.MissingProviderTransformer
2025-01-07T13:19:44.557-0800 [TRACE] (graphTransformerMulti) Completed graph transform *terraform.MissingProviderTransformer (no changes)
2025-01-07T13:19:44.557-0800 [TRACE] (graphTransformerMulti) Executing graph transform *terraform.ProviderTransformer
2025-01-07T13:19:44.557-0800 [TRACE] (graphTransformerMulti) Completed graph transform *terraform.ProviderTransformer (no changes)
2025-01-07T13:19:44.557-0800 [TRACE] (graphTransformerMulti) Executing graph transform *terraform.PruneProviderTransformer
2025-01-07T13:19:44.557-0800 [TRACE] (graphTransformerMulti) Completed graph transform *terraform.PruneProviderTransformer (no changes)
2025-01-07T13:19:44.557-0800 [TRACE] Completed graph transform *terraform.graphTransformerMulti (no changes)
2025-01-07T13:19:44.557-0800 [TRACE] Executing graph transform *terraform.RemovedModuleTransformer
2025-01-07T13:19:44.557-0800 [TRACE] Completed graph transform *terraform.RemovedModuleTransformer (no changes)
2025-01-07T13:19:44.557-0800 [TRACE] Executing graph transform *terraform.AttachSchemaTransformer
2025-01-07T13:19:44.557-0800 [TRACE] Completed graph transform *terraform.AttachSchemaTransformer (no changes)
2025-01-07T13:19:44.557-0800 [TRACE] Executing graph transform *terraform.ModuleExpansionTransformer
2025-01-07T13:19:44.557-0800 [TRACE] Completed graph transform *terraform.ModuleExpansionTransformer (no changes)
2025-01-07T13:19:44.557-0800 [TRACE] Executing graph transform *terraform.ExternalReferenceTransformer
2025-01-07T13:19:44.557-0800 [TRACE] Completed graph transform *terraform.ExternalReferenceTransformer (no changes)
2025-01-07T13:19:44.557-0800 [TRACE] Executing graph transform *terraform.ReferenceTransformer
2025-01-07T13:19:44.557-0800 [DEBUG] ReferenceTransformer: "local.foo (expand)" references: []
2025-01-07T13:19:44.557-0800 [DEBUG] ReferenceTransformer: "output.example (expand)" references: [local.foo (expand)]
2025-01-07T13:19:44.557-0800 [TRACE] Completed graph transform *terraform.ReferenceTransformer with new graph:
  local.foo (expand) - *terraform.nodeExpandLocal
  output.example (expand) - *terraform.nodeExpandOutput
    local.foo (expand) - *terraform.nodeExpandLocal
  ------
2025-01-07T13:19:44.557-0800 [TRACE] Executing graph transform *terraform.AttachDependenciesTransformer
2025-01-07T13:19:44.557-0800 [TRACE] AttachDependenciesTransformer: output.example (expand) depends on []
2025-01-07T13:19:44.557-0800 [TRACE] Completed graph transform *terraform.AttachDependenciesTransformer (no changes)
2025-01-07T13:19:44.557-0800 [TRACE] Executing graph transform *terraform.attachDataResourceDependsOnTransformer
2025-01-07T13:19:44.557-0800 [TRACE] Completed graph transform *terraform.attachDataResourceDependsOnTransformer (no changes)
2025-01-07T13:19:44.557-0800 [TRACE] Executing graph transform *terraform.DestroyEdgeTransformer
2025-01-07T13:19:44.557-0800 [TRACE] Completed graph transform *terraform.DestroyEdgeTransformer (no changes)
2025-01-07T13:19:44.557-0800 [TRACE] Executing graph transform *terraform.pruneUnusedNodesTransformer
2025-01-07T13:19:44.557-0800 [TRACE] Completed graph transform *terraform.pruneUnusedNodesTransformer (no changes)
2025-01-07T13:19:44.557-0800 [TRACE] Executing graph transform *terraform.TargetsTransformer
2025-01-07T13:19:44.557-0800 [TRACE] Completed graph transform *terraform.TargetsTransformer (no changes)
2025-01-07T13:19:44.557-0800 [TRACE] Executing graph transform *terraform.ForcedCBDTransformer
2025-01-07T13:19:44.557-0800 [TRACE] Completed graph transform *terraform.ForcedCBDTransformer (no changes)
2025-01-07T13:19:44.557-0800 [TRACE] Executing graph transform *terraform.ephemeralResourceCloseTransformer
2025-01-07T13:19:44.557-0800 [TRACE] Completed graph transform *terraform.ephemeralResourceCloseTransformer (no changes)
2025-01-07T13:19:44.557-0800 [TRACE] Executing graph transform *terraform.CloseProviderTransformer
2025-01-07T13:19:44.557-0800 [TRACE] Completed graph transform *terraform.CloseProviderTransformer (no changes)
2025-01-07T13:19:44.557-0800 [TRACE] Executing graph transform *terraform.CloseRootModuleTransformer
2025-01-07T13:19:44.557-0800 [TRACE] Completed graph transform *terraform.CloseRootModuleTransformer with new graph:
  local.foo (expand) - *terraform.nodeExpandLocal
  output.example (expand) - *terraform.nodeExpandOutput
    local.foo (expand) - *terraform.nodeExpandLocal
  root - *terraform.nodeCloseModule
    output.example (expand) - *terraform.nodeExpandOutput
  ------
2025-01-07T13:19:44.557-0800 [TRACE] Executing graph transform *terraform.TransitiveReductionTransformer
2025-01-07T13:19:44.557-0800 [TRACE] Completed graph transform *terraform.TransitiveReductionTransformer (no changes)
2025-01-07T13:19:44.557-0800 [DEBUG] Starting graph walk: walkValidate
2025-01-07T13:19:44.557-0800 [TRACE] vertex "local.foo (expand)": starting visit (*terraform.nodeExpandLocal)
2025-01-07T13:19:44.557-0800 [TRACE] vertex "local.foo (expand)": does not belong to any module instance
2025-01-07T13:19:44.557-0800 [TRACE] vertex "local.foo (expand)": expanding dynamic subgraph
2025-01-07T13:19:44.557-0800 [TRACE] Expanding local: adding local.foo as *terraform.NodeLocal
2025-01-07T13:19:44.557-0800 [TRACE] vertex "local.foo (expand)": entering dynamic subgraph
2025-01-07T13:19:44.557-0800 [TRACE] vertex "local.foo": starting visit (*terraform.NodeLocal)
2025-01-07T13:19:44.557-0800 [TRACE] vertex "local.foo": belongs to
2025-01-07T13:19:44.558-0800 [TRACE] vertex "local.foo": visit complete
2025-01-07T13:19:44.558-0800 [TRACE] vertex "root": starting visit (terraform.graphNodeRoot)
2025-01-07T13:19:44.558-0800 [TRACE] vertex "root": does not belong to any module instance
2025-01-07T13:19:44.558-0800 [TRACE] vertex "root": visit complete
2025-01-07T13:19:44.558-0800 [TRACE] vertex "local.foo (expand)": dynamic subgraph completed successfully
2025-01-07T13:19:44.558-0800 [TRACE] vertex "local.foo (expand)": visit complete
2025-01-07T13:19:44.558-0800 [TRACE] vertex "output.example (expand)": starting visit (*terraform.nodeExpandOutput)
2025-01-07T13:19:44.558-0800 [TRACE] vertex "output.example (expand)": does not belong to any module instance
2025-01-07T13:19:44.558-0800 [TRACE] vertex "output.example (expand)": expanding dynamic subgraph
2025-01-07T13:19:44.558-0800 [TRACE] Expanding output: adding output.example as *terraform.NodeApplyableOutput
2025-01-07T13:19:44.558-0800 [TRACE] vertex "output.example (expand)": entering dynamic subgraph
2025-01-07T13:19:44.558-0800 [TRACE] vertex "output.example": starting visit (*terraform.NodeApplyableOutput)
2025-01-07T13:19:44.558-0800 [TRACE] vertex "output.example": belongs to
2025-01-07T13:19:44.558-0800 [ERROR] vertex "output.example" panicked

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

Terraform crashed! This is always indicative of a bug within Terraform.
Please report the crash with Terraform[1] so that we can fix this.

When reporting bugs, please include your terraform version, the stack trace
shown below, and any additional information which may help replicate the issue.

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

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

panic: inconsistent list element types (cty.EmptyTuple then cty.Tuple([]cty.Type{cty.String}))
goroutine 64 [running]:
runtime/debug.Stack()
        runtime/debug/stack.go:26 +0x5e
github.com/hashicorp/terraform/internal/logging.PanicHandler()
        github.com/hashicorp/terraform/internal/logging/panic.go:84 +0x16a
panic({0x31598a0?, 0xc0009b4090?})
        runtime/panic.go:785 +0x132
github.com/hashicorp/terraform/internal/terraform.(*Graph).walk.func1.1()
        github.com/hashicorp/terraform/internal/terraform/graph.go:59 +0x4c5
panic({0x31598a0?, 0xc0009b4090?})
        runtime/panic.go:785 +0x132
github.com/zclconf/go-cty/cty.ListVal({0xc0009b1240, 0x2, 0x3e21190?})
        github.com/zclconf/[email protected]/cty/value_init.go:165 +0x47b
github.com/hashicorp/hcl/v2/hclsyntax.(*SplatExpr).Value(0xc000b30210, 0xc0009a85e8)
        github.com/hashicorp/hcl/[email protected]/hclsyntax/expression.go:1941 +0x1730
github.com/hashicorp/terraform/internal/lang.(*Scope).EvalExpr(0xc000708ea0, {0x3e22e08, 0xc000b30210}, {{0x3e21898?, 0x5a441c0?}})
        github.com/hashicorp/terraform/internal/lang/eval.go:179 +0x1a5
github.com/hashicorp/terraform/internal/terraform.(*BuiltinEvalContext).EvaluateExpr(0x0?, {0x3e22e08, 0xc000b30210}, {{0x3e21898?, 0x5a441c0?}}, {0x0?, 0x0?})
        github.com/hashicorp/terraform/internal/terraform/eval_context_builtin.go:331 +0xab
github.com/hashicorp/terraform/internal/terraform.(*NodeApplyableOutput).Execute(0xc0006d8a80, {0x3e48eb8, 0xc0001dad00}, 0x50?)
        github.com/hashicorp/terraform/internal/terraform/node_output.go:439 +0x6dc
github.com/hashicorp/terraform/internal/terraform.(*ContextGraphWalker).Execute(0xc0008a2420, {0x3e48eb8, 0xc0001dad00}, {0x7f9d20c9c308, 0xc0006d8a80})
        github.com/hashicorp/terraform/internal/terraform/graph_walk_context.go:161 +0xb5
github.com/hashicorp/terraform/internal/terraform.(*Graph).walk.func1({0x3534740, 0xc0006d8a80})
        github.com/hashicorp/terraform/internal/terraform/graph.go:143 +0x7c3
github.com/hashicorp/terraform/internal/dag.(*Walker).walkVertex(0xc000b53980, {0x3534740, 0xc0006d8a80}, 0xc0009a5300)
        github.com/hashicorp/terraform/internal/dag/walk.go:384 +0x2d1
created by github.com/hashicorp/terraform/internal/dag.(*Walker).Update in goroutine 58
        github.com/hashicorp/terraform/internal/dag/walk.go:307 +0xfb3

Expected Behavior

As discussed in hashicorp/hcl#723 and hashicorp/hcl#724 (comment), it's not actually clear to me what the behavior ought to have been here, since this example involves two different splat expression behaviors that (in retrospect) conflict with one another.

This appears to be a design flaw in HCL.

Actual Behavior

  • Applying [*] to a list causes HCL to try to produce a list.
  • Applying [*] to a scalar value causes HCL to try to produce a zero- or one-element tuple depending on the nullness of the value.
  • Taken together, the second rule violates an assumption being made by the first: that because all elements of a list have the same type by definition, and because a splat expression applies all of its nested steps equally to all elements of the list, that therefore all inner results should be of the same type.

An empty tuple and a one-element tuple have different types, so the outermost splat crashes by asking cty to try to construct a list using values of different types:

panic: inconsistent list element types (cty.EmptyTuple then cty.Tuple([]cty.Type{cty.String}))
goroutine 64 [running]:
runtime/debug.Stack()
        runtime/debug/stack.go:26 +0x5e
github.com/hashicorp/terraform/internal/logging.PanicHandler()
        github.com/hashicorp/terraform/internal/logging/panic.go:84 +0x16a
panic({0x31598a0?, 0xc0009b4090?})
        runtime/panic.go:785 +0x132
github.com/hashicorp/terraform/internal/terraform.(*Graph).walk.func1.1()
        github.com/hashicorp/terraform/internal/terraform/graph.go:59 +0x4c5
panic({0x31598a0?, 0xc0009b4090?})
        runtime/panic.go:785 +0x132
github.com/zclconf/go-cty/cty.ListVal({0xc0009b1240, 0x2, 0x3e21190?})
        github.com/zclconf/[email protected]/cty/value_init.go:165 +0x47b
github.com/hashicorp/hcl/v2/hclsyntax.(*SplatExpr).Value(0xc000b30210, 0xc0009a85e8)
        github.com/hashicorp/hcl/[email protected]/hclsyntax/expression.go:1941 +0x1730
github.com/hashicorp/terraform/internal/lang.(*Scope).EvalExpr(0xc000708ea0, {0x3e22e08, 0xc000b30210}, {{0x3e21898?, 0x5a441c0?}})
        github.com/hashicorp/terraform/internal/lang/eval.go:179 +0x1a5
github.com/hashicorp/terraform/internal/terraform.(*BuiltinEvalContext).EvaluateExpr(0x0?, {0x3e22e08, 0xc000b30210}, {{0x3e21898?, 0x5a441c0?}}, {0x0?, 0x0?})
        github.com/hashicorp/terraform/internal/terraform/eval_context_builtin.go:331 +0xab
github.com/hashicorp/terraform/internal/terraform.(*NodeApplyableOutput).Execute(0xc0006d8a80, {0x3e48eb8, 0xc0001dad00}, 0x50?)
        github.com/hashicorp/terraform/internal/terraform/node_output.go:439 +0x6dc
github.com/hashicorp/terraform/internal/terraform.(*ContextGraphWalker).Execute(0xc0008a2420, {0x3e48eb8, 0xc0001dad00}, {0x7f9d20c9c308, 0xc0006d8a80})
        github.com/hashicorp/terraform/internal/terraform/graph_walk_context.go:161 +0xb5
github.com/hashicorp/terraform/internal/terraform.(*Graph).walk.func1({0x3534740, 0xc0006d8a80})
        github.com/hashicorp/terraform/internal/terraform/graph.go:143 +0x7c3
github.com/hashicorp/terraform/internal/dag.(*Walker).walkVertex(0xc000b53980, {0x3534740, 0xc0006d8a80}, 0xc0009a5300)
        github.com/hashicorp/terraform/internal/dag/walk.go:384 +0x2d1
created by github.com/hashicorp/terraform/internal/dag.(*Walker).Update in goroutine 58
        github.com/hashicorp/terraform/internal/dag/walk.go:307 +0xfb3

Steps to Reproduce

Use the configuration I shared above with terraform plan.

Terraform should crash as soon as graph traversal reaches the output value named "example".

Additional Context

There is a more complete -- but also significantly more complicated -- example of this problem in opentofu/opentofu#2327, since this problem was originally discovered by an OpenTofu user.

I'm opening an issue here only to help with prioritization, as requested in hashicorp/hcl#724.

References

opentofu/opentofu#2327 - original bug report for OpenTofu's version of this bug
hashicorp/hcl#723 - HCL bug report based on the OpenTofu bug
hashicorp/hcl#724 - My initial attempt to "fix" this by making it return a normal error instead of crashing

Generative AI / LLM assisted development?

I have not used any generative AI for any part of this bug report.

@crw
Copy link
Contributor

crw commented Jan 7, 2025

Ha, thanks @apparentlymart!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug new new issue not yet triaged
Projects
None yet
Development

No branches or pull requests

2 participants