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

transpose panics on null input #36547

Open
rwblokzijl opened this issue Feb 20, 2025 · 1 comment
Open

transpose panics on null input #36547

rwblokzijl opened this issue Feb 20, 2025 · 1 comment
Assignees

Comments

@rwblokzijl
Copy link

Terraform Version

Terraform v1.10.5
on linux_amd64

Terraform Configuration Files

output "output_name" {
  value = transpose({ "test" = null })
}

Debug Output

2025-02-20T16:16:24.710+0100 [INFO]  Terraform version: 1.10.5
2025-02-20T16:16:24.710+0100 [DEBUG] using github.com/hashicorp/go-tfe v1.70.0
2025-02-20T16:16:24.710+0100 [DEBUG] using github.com/hashicorp/hcl/v2 v2.23.0
2025-02-20T16:16:24.710+0100 [DEBUG] using github.com/hashicorp/terraform-svchost v0.1.1
2025-02-20T16:16:24.710+0100 [DEBUG] using github.com/zclconf/go-cty v1.16.2
2025-02-20T16:16:24.710+0100 [INFO]  Go runtime version: go1.23.3
2025-02-20T16:16:24.710+0100 [INFO]  CLI args: []string{"terraform", "plan", "-refresh=false"}
2025-02-20T16:16:24.710+0100 [DEBUG] Attempting to open CLI config file: /home/bloodyfool/.terraformrc
2025-02-20T16:16:24.710+0100 [DEBUG] File doesn't exist, but doesn't need to. Ignoring.
2025-02-20T16:16:24.710+0100 [INFO]  Loading CLI configuration from /home/bloodyfool/.terraform.d/credentials.tfrc.json
2025-02-20T16:16:24.710+0100 [DEBUG] ignoring non-existing provider search directory terraform.d/plugins
2025-02-20T16:16:24.710+0100 [DEBUG] ignoring non-existing provider search directory /home/bloodyfool/.terraform.d/plugins
2025-02-20T16:16:24.710+0100 [DEBUG] ignoring non-existing provider search directory /home/bloodyfool/.local/share/terraform/plugins
2025-02-20T16:16:24.710+0100 [DEBUG] ignoring non-existing provider search directory /usr/share/i3-gnome/terraform/plugins
2025-02-20T16:16:24.710+0100 [DEBUG] ignoring non-existing provider search directory /usr/share/gnome/terraform/plugins
2025-02-20T16:16:24.710+0100 [DEBUG] ignoring non-existing provider search directory /usr/local/share/terraform/plugins
2025-02-20T16:16:24.710+0100 [DEBUG] ignoring non-existing provider search directory /usr/share/terraform/plugins
2025-02-20T16:16:24.710+0100 [DEBUG] ignoring non-existing provider search directory /var/lib/snapd/desktop/terraform/plugins
2025-02-20T16:16:24.710+0100 [DEBUG] ignoring non-existing provider search directory /home/bloodyfool/.nix-profile/share/terraform/plugins
2025-02-20T16:16:24.710+0100 [DEBUG] ignoring non-existing provider search directory /nix/var/nix/profiles/default/share/terraform/plugins
2025-02-20T16:16:24.710+0100 [DEBUG] ignoring non-existing provider search directory /home/bloodyfool/.nix-profile/share/terraform/plugins
2025-02-20T16:16:24.710+0100 [DEBUG] ignoring non-existing provider search directory /nix/var/nix/profiles/default/share/terraform/plugins
2025-02-20T16:16:24.710+0100 [INFO]  CLI command args: []string{"plan", "-refresh=false"}
2025-02-20T16:16:24.711+0100 [DEBUG] checking for provisioner in "."
2025-02-20T16:16:24.711+0100 [DEBUG] checking for provisioner in "/home/bloodyfool/bin"
2025-02-20T16:16:24.711+0100 [INFO]  backend/local: starting Plan operation
2025-02-20T16:16:24.711+0100 [DEBUG] Building and walking validate graph
2025-02-20T16:16:24.711+0100 [DEBUG] ReferenceTransformer: "output.output_name (expand)" references: []
2025-02-20T16:16:24.711+0100 [DEBUG] Starting graph walk: walkValidate
2025-02-20T16:16:24.712+0100 [ERROR] vertex "output.output_name" error: Error in function call
2025-02-20T16:16:24.712+0100 [ERROR] vertex "output.output_name (expand)" error: Error in function call
╷
│ Error: Error in function call
│
│   on main.tf line 2, in output "output_name":
│    2:   value = transpose({ "test" = null })
│     ├────────────────
│     │ while calling transpose(values)
│
│ Call to function "transpose" failed: panic in function implementation: can't use ElementIterator on null value
│ goroutine 72 [running]:
│ runtime/debug.Stack()
│ 	runtime/debug/stack.go:26 +0x5e
│ github.com/zclconf/go-cty/cty/function.errorForPanic(...)
│ 	github.com/zclconf/[email protected]/cty/function/error.go:44
│ github.com/zclconf/go-cty/cty/function.Function.Call.func2()
│ 	github.com/zclconf/[email protected]/cty/function/function.go:349 +0x9b
│ panic({0x3050ca0?, 0x3ddb130?})
│ 	runtime/panic.go:785 +0x132
│ github.com/zclconf/go-cty/cty.Value.ElementIterator({{{0x3e21418?, 0xc0007f76f0?}}, {0x0?, 0x0?}})
│ 	github.com/zclconf/[email protected]/cty/value_ops.go:1219 +0xbe
│ github.com/hashicorp/terraform/internal/lang/funcs.init.func19({0xc0009a19a0?, 0xc0007f7740?, 0x3198f00?}, {{0x3e21248?, 0xc00058fb70?}})
│ 	github.com/hashicorp/terraform/internal/lang/funcs/collection.go:585 +0x20d
│ github.com/zclconf/go-cty/cty/function.Function.Call({0x3e21210?}, {0xc0009a19a0, 0x1, 0x1})
│ 	github.com/zclconf/[email protected]/cty/function/function.go:353 +0x6bf
│ github.com/hashicorp/hcl/v2/hclsyntax.(*FunctionCallExpr).Value(0xc0009c0000, 0xc0007f38a8)
│ 	github.com/hashicorp/hcl/[email protected]/hclsyntax/expression.go:528 +0x1acf
│ github.com/hashicorp/terraform/internal/lang.(*Scope).EvalExpr(0xc0003a4d80, {0x3e21828, 0xc0009c0000}, {{0x3e21918?, 0x5a441a0?}})
│ 	github.com/hashicorp/terraform/internal/lang/eval.go:179 +0x1a5
│ github.com/hashicorp/terraform/internal/terraform.(*BuiltinEvalContext).EvaluateExpr(0x0?, {0x3e21828, 0xc0009c0000}, {{0x3e21918?, 0x5a441a0?}}, {0x0?, 0x0?})
│ 	github.com/hashicorp/terraform/internal/terraform/eval_context_builtin.go:331 +0xab
│ github.com/hashicorp/terraform/internal/terraform.(*NodeApplyableOutput).Execute(0xc0005ea600, {0x3e48f38, 0xc000124700}, 0x50?)
│ 	github.com/hashicorp/terraform/internal/terraform/node_output.go:439 +0x6dc
│ github.com/hashicorp/terraform/internal/terraform.(*ContextGraphWalker).Execute(0xc0009fa000, {0x3e48f38, 0xc000124700}, {0x7c044224bb68, 0xc0005ea600})
│ 	github.com/hashicorp/terraform/internal/terraform/graph_walk_context.go:161 +0xb5
│ github.com/hashicorp/terraform/internal/terraform.(*Graph).walk.func1({0x3534740, 0xc0005ea600})
│ 	github.com/hashicorp/terraform/internal/terraform/graph.go:143 +0x7c3
│ github.com/hashicorp/terraform/internal/dag.(*Walker).walkVertex(0xc0009b9800, {0x3534740, 0xc0005ea600}, 0xc0007faec0)
│ 	github.com/hashicorp/terraform/internal/dag/walk.go:384 +0x2d1
│ created by github.com/hashicorp/terraform/internal/dag.(*Walker).Update in goroutine 70
│ 	github.com/hashicorp/terraform/internal/dag/walk.go:307 +0xfb3
│ .
╵

Expected Behavior

No Panic

Actual Behavior

Panic

Steps to Reproduce

terraform plan

Additional Context

No response

References

No response

Generative AI / LLM assisted development?

No response

@rwblokzijl rwblokzijl added bug new new issue not yet triaged labels Feb 20, 2025
@radeksimko radeksimko self-assigned this Feb 21, 2025
@radeksimko
Copy link
Member

I was able to reproduce this with the latest build e329cf26558c6f82e33ce9f15cff9f366da3c7ef

Thanks for the report.

@radeksimko radeksimko added crash and removed new new issue not yet triaged labels Feb 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants