FusionAuth / terraform-provider-fusionauth

FusionAuth Terraform Provider
https://registry.terraform.io/providers/FusionAuth/fusionauth/latest
Apache License 2.0
35 stars 53 forks source link

When application.data contains an array getting Error expected type 'string' #240

Open Aaron-Ritter opened 11 months ago

Aaron-Ritter commented 11 months ago

When the following data is stored in the application data in a valid json format:

{
  "defaultLanguage" : "de",
  "languages" : [ "de", "fr", "en" ]
}

It will complain with the following error:

│ Error: application.data: data.languages: '' expected type 'string', got unconvertible type '[]interface {}', value: '[de fr en]'
│ 
│   with fusionauth_application.syrakus-oldcapitol,
│   on syrakus-oldcapitol.tf line 6, in resource "fusionauth_application" "syrakus-oldcapitol":
│    6: resource "fusionauth_application" "syrakus-oldcapitol" {
Aaron-Ritter commented 9 months ago

related issues https://github.com/FusionAuth/terraform-provider-fusionauth/issues/256 https://github.com/FusionAuth/terraform-provider-fusionauth/issues/63

The current provider only validates for schema.TypeMap: https://github.com/FusionAuth/terraform-provider-fusionauth/blob/5698966878108b4a260a8aa49744ffa49f370d1e/fusionauth/resource_fusionauth_application.go#L91-L95

Where for user.data it does some json related function in dataToUserRequest:

https://github.com/FusionAuth/terraform-provider-fusionauth/blob/5698966878108b4a260a8aa49744ffa49f370d1e/fusionauth/resource_fusionauth_user.go#L130-L133

with jsonStringToMapStringInterface

https://github.com/FusionAuth/terraform-provider-fusionauth/blob/5698966878108b4a260a8aa49744ffa49f370d1e/fusionauth/helpers.go#L69-L91

and userResponseToData:

https://github.com/FusionAuth/terraform-provider-fusionauth/blob/5698966878108b4a260a8aa49744ffa49f370d1e/fusionauth/resource_fusionauth_user.go#L186-L190

with mapStringInterfaceToJSONString

https://github.com/FusionAuth/terraform-provider-fusionauth/blob/5698966878108b4a260a8aa49744ffa49f370d1e/fusionauth/helpers.go#L95-L115