You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
aclarke822 opened this issue
Mar 7, 2025
· 1 comment
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
Hi @aclarke822, thanks for filing this. I've marked this as confirmed as I can replicate it.
Interestingly enough it does return an error if you the template isn't just a single reference: template = "this: $${test}".
╷
│ Error: Error in function call
│
│ on main.tf line 7, in locals:
│ 7: test = templatestring(local.template, local.map)
│ ├────────────────
│ │ while calling templatestring(template, vars)
│ │ local.map is object with 1 attribute "test"
│ │ local.template is "this: ${test}"
│
│ Call to function "templatestring" failed: <templatestring argument>:1,9-13: Invalid template interpolation value; The expression result is null. Cannot include a null
│ value in a string template..
╵
The implementation of this function is actually directly within HCL, so I've tagged this as an upstream issue and we'll have to fix this within HCL. I think that HCL is trying to be clever in the way it interprets this, and realises it doesn't need to do any string interpolation with the original template so it appears to incorrectly skip the necessary validation. We need to make it perform the same validation even when it isn't actually performing any real templating.
bugconfirmeda Terraform Core team member has reproduced this issuehclUse in conjunction with "upstream" when HCL is the relevant upstreamnewnew issue not yet triagedupstream
Terraform Version
Terraform Configuration Files
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
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
The text was updated successfully, but these errors were encountered: