Error: Provider produced inconsistent result after apply for new terraform plugin provider

Hey Team,

I was working on writing terraform provider for one of our products, using terraform-plugin-framework. I’m observing few challenges, Please help me with this.

After apply, i get below error,

╷
│ Error: Provider produced inconsistent result after apply
│ 
│ When applying changes to netscalersdx_mpsgroup.tf_mpsgroup, provider "provider[\"registry.terraform.io/netscaler/netscalersdx\"]" produced an unexpected new value: .assign_all_devices: was null, but now cty.False.
│ 
│ This is a bug in the provider, which should be reported in the provider's own issue tracker.
╵
╷
│ Error: Provider produced inconsistent result after apply
│ 
│ When applying changes to netscalersdx_mpsgroup.tf_mpsgroup, provider "provider[\"registry.terraform.io/netscaler/netscalersdx\"]" produced an unexpected new value: .bound_entity_selected: was null, but now cty.NumberIntVal(0).
│ 
│ This is a bug in the provider, which should be reported in the provider's own issue tracker.
╵
╷
│ Error: Provider produced inconsistent result after apply
│ 
│ When applying changes to netscalersdx_mpsgroup.tf_mpsgroup, provider "provider[\"registry.terraform.io/netscaler/netscalersdx\"]" produced an unexpected new value: .assign_all_autoscale_groups: was null, but now cty.True.
│ 
│ This is a bug in the provider, which should be reported in the provider's own issue tracker.
╵
╷
│ Error: Provider produced inconsistent result after apply
│ 
│ When applying changes to netscalersdx_mpsgroup.tf_mpsgroup, provider "provider[\"registry.terraform.io/netscaler/netscalersdx\"]" produced an unexpected new value: .tenant_id: was null, but now
│ cty.StringVal("12345f67h89j0").
│ 
│ This is a bug in the provider, which should be reported in the provider's own issue tracker.
╵

my schema for one of the attribute is:

"tenant_id": schema.StringAttribute{
	Optional:            true,
	Description:         "Id of the tenant. Minimum length =  1 Maximum length =  128",
	MarkdownDescription: "Id of the tenant. Minimum length =  1 Maximum length =  128",
},

And in the Read method, I’m setting the values if only its not empty

if getResponseData["tenant_id"] != "" {
	data.TenantId = types.StringValue(getResponseData["tenant_id"].(string))
}

There is the similar configuration to all the other attributes.

Hi @rohit-myali :wave:

Sorry you ran into trouble here.

I believe the issue you are encountering is because the value supplied for these attributes (e.g., tenant_id) is implicitly null when they are omitted from configuration, and you are then mutating this value. If the attributes should permit either having a value set in Terraform configuration, or having the value set within the provider itself, when there is no value supplied in the configuration, then the attributes should be marked as Optional and Computed. Further information which may be useful includes Handling Data - Terraform Concepts, and Configurability for individual attribute types.