# TypeSet with computed attributes alway returns dirty plan

**URL:** <https://discuss.hashicorp.com/t/typeset-with-computed-attributes-alway-returns-dirty-plan/53014>\
**Category:** Plugin Development\
**Created:** [April 22, 2023, 10:41am UTC](https://discuss.hashicorp.com/t/typeset-with-computed-attributes-alway-returns-dirty-plan/53014 "2023-04-22T10:41:04Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![OrNovo](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/ornovo/32/35329_2.png) [@OrNovo](https://discuss.hashicorp.com/u/OrNovo)\
**Post date:** [April 22, 2023, 10:41am UTC](https://discuss.hashicorp.com/t/typeset-with-computed-attributes-alway-returns-dirty-plan/53014/1 "2023-04-22T10:41:04Z")

</div>

I’m using terraform-plugin-sdk to write a provider and it has a TypeSet which contains computed attributes (which also contain computed nested attributes).

```auto
"metric_fields": {
			Type: schema.TypeSet,
			Optional: true,
			Elem: &schema.Resource{
				Schema: map[string]*schema.Schema{
					"aggregations": {
						Type: schema.TypeList,
						MaxItems: 1,
						Optional: true,
						Computed: true,
						Elem: &schema.Resource{
							Schema: map[string]*schema.Schema{
                                                        ....
					},
				},
			},
		},

```

After applying, the plan phase always returns not empty.  
when I change it from TypeSet to TypeList It doesn’t seem to be reproduced.

What is the best practice to handle this issue?

---

<div class="post-metadata">

**Author:** ![jbardin](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/jbardin/32/3325_2.png) [@jbardin](https://discuss.hashicorp.com/u/jbardin)\
**Post date:** [April 24, 2023, 12:25pm UTC](https://discuss.hashicorp.com/t/typeset-with-computed-attributes-alway-returns-dirty-plan/53014/2 "2023-04-24T12:25:49Z")

</div>

Hi @OrNovo,

I would first make sure you are using the latest SDK and Terraform cli versions. I don’t know what the missing section of schema is, or what the plan is showing as changed, but the reason is probably something not set correctly during apply, which is being reverted during the next plan. You may be able to better determine what is happening by looking for warnings about the resource in the core logs, both when using the set type, and a list.

The legacy SDK can’t correctly handle nested types like this in many cases, so if you are working on a new provider, you may want to look into using the [Plugin Framework](https://developer.hashicorp.com/terraform/plugin/framework) instead.

---

<div class="post-metadata">

**Author:** ![OrNovo](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/ornovo/32/35329_2.png) [@OrNovo](https://discuss.hashicorp.com/u/OrNovo)\
**Post date:** [April 24, 2023, 1:07pm UTC](https://discuss.hashicorp.com/t/typeset-with-computed-attributes-alway-returns-dirty-plan/53014/4 "2023-04-24T13:07:51Z")

</div>

Thanks for answering!

---

<div class="post-metadata">

**Author:** ![OrNovo](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/ornovo/32/35329_2.png) [@OrNovo](https://discuss.hashicorp.com/u/OrNovo)\
**Post date:** [March 6, 2024, 9:00am UTC](https://discuss.hashicorp.com/t/typeset-with-computed-attributes-alway-returns-dirty-plan/53014/5 "2024-03-06T09:00:43Z")

</div>

Hi @jbardin .  
using `CustomizeDiff` can help with that maybe?

---

<div class="post-metadata">

**Author:** ![jbardin](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/jbardin/32/3325_2.png) [@jbardin](https://discuss.hashicorp.com/u/jbardin)\
**Post date:** [March 6, 2024, 2:20pm UTC](https://discuss.hashicorp.com/t/typeset-with-computed-attributes-alway-returns-dirty-plan/53014/6 "2024-03-06T14:20:10Z")

</div>

It’s possible that `CustomizeDiff` might be part of a solution, but I can’t say without seeing the entire problem. If you can’t move away from the legacy SDK yet, any warnings in the core logs referring to that resource would be a good place to start investigating. If there are no warnings, then the plan+apply were at least valid, and the changes shown in the next plan should indicate what the provider needs to do to converge on a stable state,

---

<div class="post-metadata">

**Author:** ![austin.valle](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/austin.valle/32/33332_2.png) [@austin.valle](https://discuss.hashicorp.com/u/austin.valle)\
**Post date:** [March 6, 2024, 2:57pm UTC](https://discuss.hashicorp.com/t/typeset-with-computed-attributes-alway-returns-dirty-plan/53014/7 "2024-03-06T14:57:34Z")

</div>

Just to plug some recently written docs: [https://developer.hashicorp.com/terraform/plugin/sdkv2/resources/data-consistency-errors#finding-data-consistency-errors](https://developer.hashicorp.com/terraform/plugin/sdkv2/resources/data-consistency-errors#finding-data-consistency-errors)

This should help you determine if what you have written follows Terraform’s data consistency rules.
