Skip to content

templatestring Function Crashes When Map Contains a Key Mapped to null #36652

@aclarke822

Description

@aclarke822

Terraform Version

Terraform v1.11.1
on windows_amd64

Terraform Configuration Files

locals {
  map = {
    test = null
  }
  template = "$${test}"

  test = templatestring(local.template, local.map)
}

output "test" {
  value = local.test
}

Debug Output

https://gist.github.com/aclarke822/db92ba7a7a8a95851a9911db75dc7191

Expected Behavior

Terraform should handle this scenario gracefully, without crashing and output a relevant error message.

Actual Behavior

Terraform crashes.

Steps to Reproduce

  1. terraform apply

Additional Context

Also tested on 1.9.8 and 1.10.5 with the same result

References

No response

Generative AI / LLM assisted development?

No response

Metadata

Metadata

Assignees

Labels

bugconfirmeda Terraform Core team member has reproduced this issuehclUse in conjunction with "upstream" when HCL is the relevant upstreamnewnew issue not yet triagedupstream

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions