Provider functions: if object parameter with map field has an unknown value on any entry in the nested map, the entire parameter is unknown #1089
Labels
bug
Something isn't working
waiting-response
Issues or pull requests waiting for an external response
I have a provider which computes names for resources. I try to have this computation work at plan time if at all possible. One issue is that there are times that a random component would be needed in the computed name. I'm using
terraform_data
in my acceptance test to simulaterandom_string
(but with a known value). The currently published version of the provider does not allow any parameters to be unknown but I am working on a version which allows them to be unknown and simply computes the name in cases where it can and returns unknown where it relies on unknown data.The issue is that the configuration for this function is an object with nested maps and map of map fields which configure how the name computation should be done. In the version I'm working on, I try to handle values which can be unknown and I set the
configuration
parameter to allow unknown values. Unfortunately, even with just a single element of one of the nested maps set toterraform_data.test.output
, the entire argument is passed to the function as unknown. I thought the issue might have to do with the struct I was converting to but when inspecting in the debugger, I see that theconfiguration
argument is already unknown. I checked in the call stack further into the plugin framework code and it seems this unknown value is passed from the terraform server directly (theUnmarshall
function gets unknown already). From reading the documentation and various issues on the subject, I was under the impression that everything would be known except this exact value which is unknown.Apologies if the linked code is a bit "busy" but I have linked directly to the relevant lines. The line in the test is the only relevant one which puts this "unknown at plan time" value into the configuration. If I change that value to be a string instead of referencing the
terraform_data
entry then everything is known at plan time. The linked location in the provider is the area one can stop with the debugger to verify that the second parameter (configuration
) is unknown.Module version
Relevant provider source code
Function test (relevant line)
Function error location
Terraform Configuration Files
In the test (there is only one to make it easier to see the issue)
Expected Behavior
I expected all parameters to be defined, but a single value in the
variables
nested map to beUnKnown
at plan time.Actual Behavior
The entire
configuration
parameters value is set to unknown.Steps to Reproduce
If the test is run, as is, it gets a null deference crash because I didn't handle the "should be impossible" case of
configuration
being unknown. However, if a breakpoint is set in the provider function code at the location shown, it is possible to inspectreq.Arguments
and verify thatconfiguration
is unknown.The text was updated successfully, but these errors were encountered: