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
tostring does not behave as documented #30899
Comments
Hi @cromega, Thanks for filing the issue. This is being taken care of in #30879. In most cases the The expected result however is not an empty string, which is distinct from a Thanks |
Hi @cromega! Thanks for reporting this. As @jbardin noted, we already by coincidence had #30879 open after we learned about this incorrect behavior from another issue opened recently. That is now merged and will be included in the forthcoming v1.2.0 release. @jbardin also mentioned that your "Expected Behavior" doesn't match the intended and documented design of functions like
This particular example seems a bit silly because
In the above example, Terraform saw that the element types of If you want to write an expression which takes a possibly-null string and returns a definitely-not-null string with
Because of that, I think the most straightforward way to write such an expression would be using the conditional operator: var.example != null ? var.example : "" Since #30879 has now fixed the bug (albeit not exactly in the way you expected), I'm going to close this issue. Thanks again for reporting it! |
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. |
The documentation says that:
However, quite clearly, tostring does not perform a type conversion for
null
values:Terraform Version
Expected Behavior
The text was updated successfully, but these errors were encountered: