-
Notifications
You must be signed in to change notification settings - Fork 9.6k
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
0.13 function merge() returns null #26268
Comments
Hi @zamerman! Thanks for this bug report. I reproduced this easily using
In the implementation of this function, it seems like it's intentionally accepting and ignoring
...and so this behavior of I think in order to decide what to do here we'll need to first do some code archaeology to determine what prompted having the |
I did some digging, and this function has been largely unchanged since it was brought over to go-cty from terraform v0.11. There are no comments and no documentation that describe why this choice was made, so I think we're ok to (cautiously) change it for v0.15: Since terraform v0.11 didn't have a concept of null values, and merge would return an error if there were no arguments, I'm inclined to update the behavior so it will return an error if there are no arguments or if all arguments are null, while still accepting This is the closest one could get to merging "null" in v0.11:
Empty maps are fine (non-null) in v0.11:
|
👋 Sorry for the delay! I made this change in go-cty and failed to link that upstream PR : zclconf/go-cty#82 The cty dependency has been updated in terraform, so I will close this. Thanks!
|
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. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further. |
Terraform Version
Terraform Configuration Files
Debug Output
Crash Output
Expected Behavior
According to the documentation, "
merge
takes an arbitrary number of maps or objects, and returns a single map or object that contains a merged set of elements from all arguments." So the result should be something like:Actual Behavior
In reality when the merge function has no parameters it returns
null
.out2
andout3
outputs are suppressed. Therefore in cases in which the return of the merge function is used by some other function or code expecting a list the code fails.Steps to Reproduce
terraform init
terraform apply
Additional Context
Our code is using the return of the merge function in the transpose function. The transpose function expects a map and its argument cannot be null. So we receive the following error:
Our code worked in Terraform 0.12, it is only after changing to Terraform 0.13 that the error occurred. So this is a behavior change from 0.12 to 0.13.
References
The text was updated successfully, but these errors were encountered: