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
data"provider_dummy""test" {
dynamic_attribute ="hello"
regular_attribute ="bye"regular_block {
bar ="bar"
foo =3
}
dynamic_block {
bar ="bar"
foo =4
}
}
Expected Behavior
it should be able to create a statefile, this behavior is happening if your remove the DPT of the dynamic_block schema and change it to a string, (tftypes.String instead of tftypes.DynamicPseudoType )
Actual Behavior
A panic is produced
2023-02-28T17:19:19.961-0600 [ERROR] sdk.proto: Error from downstream: tf_proto_version=5.3 tf_rpc=ReadDataSource tf_data_source_type=provider_dummy tf_req_id=4939bb6e-c465-28c6-470f-5a42012f85e4 error="Cant unmarshall config input, AttributeName(\"dynamic_block\").ElementKeyInt(0): error decoding object length: msgpack: invalid code=c4 decoding map length" tf_provider_addr=registry.terraform.io/hashicorp/provider
provider_low_example/internal/data_dummy/dummy_data_test.go:21: Step 1/1 error: Error running pre-apply refresh: exit status 1
Error: Plugin error
with data.provider_dummy.test,
on terraform_plugin_test.tf line 3, in data "provider_dummy" "test":
3: data "provider_dummy" "test" {
The plugin returned an unexpected error from
plugin.(*GRPCProvider).ReadDataSource: rpc error: code = Unknown desc = Cant
unmarshall config input, AttributeName("dynamic_block").ElementKeyInt(0):
error decoding object length: msgpack: invalid code=c4 decoding map length
Inspecting with the debugger I found the following:
Changing the nesting mode in the block attributes changes the behavior of the types
set won't accept dynamic pseudotypes
list accept them, but the lib that is unmarshalling the bytes from the RCP (github.com/vmihailenco/msgpack/v4) is having problems reading the decoded state
it is raising a panic because it cant parse the hex value of 0xC4, which is what is passing the length value of the list
fail decoding, testName: decoded_with_dpt_block error -> AttributeName("dynamic_block"): error decoding object length: msgpack: invalid code=92 decoding map length
Nciso
changed the title
Dynamic Pseudo Types inside of Blocks with nested mode of list cant be unmarshalled to tftyvalues
Dynamic Pseudo Types inside of Blocks with nested mode of list cant be unmarshalled to tfvalues
Feb 28, 2023
Example usage of TF mux and plugin go.
There seems to be some limitations around using `DynamicPseudoType` with
lists and the TF docs generation tool lack support for tuples. So for
now it's better to stick to plugin framework only.
Ref: hashicorp/terraform-plugin-go#267
Signed-off-by: Noel Georgi <git@frezbo.dev>
terraform-plugin-go version
Relevant provider source code
E2E test https://github.com/Nciso/low_level_provider_example/blob/main/internal/data_dummy/dummy_data_test.go#L17
Terraform Configuration Files
Expected Behavior
it should be able to create a statefile, this behavior is happening if your remove the DPT of the
dynamic_block
schema and change it to a string, (tftypes.String
instead oftftypes.DynamicPseudoType
)Actual Behavior
A panic is produced
Steps to Reproduce
Run the following test
https://github.com/Nciso/low_level_provider_example/blob/main/internal/data_dummy/dummy_data_test.go#L17
References
Inspecting with the debugger I found the following:
Changing the nesting mode in the block attributes changes the behavior of the types
fail decoding,
testName: decoded_with_dpt_block error -> AttributeName("dynamic_block"): error decoding object length: msgpack: invalid code=92 decoding map length
When the terraform core code is reached, there is a conversion from the schema to a cty.Value, if a block contains a DPT it will change the whole root attribute of the block to a DTP instead of changing the local attribute, https://github.com/hashicorp/terraform-plugin-sdk/blob/main/internal/configs/configschema/implied_type.go#L40
Also this is the code that is not allowing DPT in sets, https://github.com/hashicorp/terraform-plugin-sdk/blob/main/internal/configs/configschema/implied_type.go#L47
Once the cty value reaches to
objchange
in theterraform plan
time, it panics because the cty.object was transformed to a cty.dynamicPseudoType in the above step https://github.com/hashicorp/terraform/blob/main/internal/plans/objchange/objchange.go#L71The text was updated successfully, but these errors were encountered: