Cannot convert Map to tftypes.Value if ElemType field is not set

Hi there! I am the developer for a terraform-plugin-framework based provider and have hit a bit of a snag. Iā€™m trying to add an attribute with a MapType to one of my resources. I have it defined in my ResourceData struct as so:

Secrets types.Map    `tfsdk:"secrets"`

and in my attributes map:

"secrets": {
        Sensitive:           true,
        Optional:            true,
        MarkdownDescription: "App secrets",
        Type:                types.MapType{ElemType: types.StringType},
},

The problem arises because if I try to use the resoruce in any way, specifying the secrets attribute or not, I get this error:

ā”‚ An unexpected error was encountered trying to convert the Attribute value into a Terraform value. This is always an error in the provider. Please report the following to the provider developer:
ā”‚ 
ā”‚ cannot convert Map to tftypes.Value if ElemType field is not set

Except that I am pretty confident ElemType is in fact set. This is the same way I use MapTypes elsewhere in my provider so I am a bit confused. Any ideas?

1 Like

I also just ran into this. Were you ever able to solve it?