# Terraform plan detects false changes, and doesn't show it in the output

**URL:** <https://discuss.hashicorp.com/t/terraform-plan-detects-false-changes-and-doesnt-show-it-in-the-output/62849>\
**Category:** Plugin Development\
**Created:** [February 16, 2024, 3:32pm UTC](https://discuss.hashicorp.com/t/terraform-plan-detects-false-changes-and-doesnt-show-it-in-the-output/62849 "2024-02-16T15:32:01Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![AmadeusK525](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/amadeusk525/32/40395_2.png) [@AmadeusK525](https://discuss.hashicorp.com/u/AmadeusK525)\
**Post date:** [February 16, 2024, 3:32pm UTC](https://discuss.hashicorp.com/t/terraform-plan-detects-false-changes-and-doesnt-show-it-in-the-output/62849/1 "2024-02-16T15:32:01Z")

</div>

Hello, I’m developing a Terraform provider and I’ve been dealing with a very weird behavior in two of my Resources. I’m gonna talk about one of them but the issue is the same in the other one.

I have a Resource with an attribute called `auto_scale`, which is a `SingleNestedAttribute` and it has two children, `max` and `min`, both `Int64Attributes`.  
The `auto_scale` attribute, which is the “parent” object attribute, is Optional and Computed and it has the `UseStateForUnknown` modifier.

When creating the Resource, I DON’T specify the `auto_scale` attribute. It doesn’t have a default value so the server will decide what the value will be. This means that the attribute is NOT in my `.tf` file. I create the Resource, everything goes well, and I get a success response. When inspecting the state file, `auto_scale` has the following value:

```json
"auto_scale": {
  "max": 2,
  "min": 2
}

```

Everything looks fine, but the next time I run `terraform plan` without changing anything in my `.tf` file, Terraform will detect changes. The weird thing is that the plan output only shows attributes that will be known after apply (they don’t use state for unknown). There is no attribute that explicitly shows its current value and the proposed new value. And get this, `auto_scale` doesn’t even show up in the output (it’s probably in the `6 unchanged attributes hidden` section). If I apply the changes, nothing will be done, since my code only updates attributes it needs to (and, unlike what Terraform thinks, nothings needs an update), Terraform will report success, but when planning again the same issue will happen.

I know that `auto_scale` is the attribute causing the issue because of the following log message:

```auto
2024-02-16T11:16:48.833-0300 [DEBUG] provider.terraform-provider-<redacted>: Detected value change between proposed new state and prior state: tf_provider_addr=registry.terraform.io/<redacted> tf_req_id=09b172bb-c42d-259d-ddc5-cc5e6a032876 tf_rpc=PlanResourceChange tf_attribute_path=auto_scale tf_resource_type=<redacted> @caller=/Users/amadeusk525/go/pkg/mod/github.com/hashicorp/terraform-plugin-framework@v1.3.4/internal/fwserver/server_planresourcechange.go:186 @module=sdk.framework timestamp=2024-02-16T11:16:48.829-0300

```

The weird thing is that some log message BEFORE that one, I have the following:

```auto
Value switched to prior value due to semantic equality logic: tf_attribute_path=auto_scale.max
Value switched to prior value due to semantic equality logic: tf_attribute_path=auto_scale.min
Value switched to prior value due to semantic equality logic: tf_attribute_path=auto_scale

```

This should mean that `auto_scale` was detected as unchanged, right? Why does it all of the sudden detect changes later on? And it doesn’t even show the changes in the output! I hope someone can share some light on this, as I’ve been having a hard time trying to fix the issue. The other Resource with this problem is being triggered by a `StringAttribute`, so I don’t think that the fact that `auto_scale` is an object matters. In that case, `user_data` (the string attribute) does show up in the plan output but only because it forces a replacement when changed, but it shows up like this:

```auto
+ user_data = (known after apply) # forces replacement

```

---

<div class="post-metadata">

**Author:** ![bendbennett](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/bendbennett/32/30764_2.png) [@bendbennett](https://discuss.hashicorp.com/u/bendbennett)\
**Post date:** [February 19, 2024, 8:34am UTC](https://discuss.hashicorp.com/t/terraform-plan-detects-false-changes-and-doesnt-show-it-in-the-output/62849/2 "2024-02-19T08:34:22Z")

</div>

Hi @AmadeusK525 👋

Sorry you ran into trouble here.

It would be very helpful if you could supply a minimal reproducible example which includes:

- Terraform configuration (i.e., what is in your `.tf` file during create, and subsequently).
- The code for your provider resource schema.
- The code for the CRUD functions in your provider resource.

This will help narrow down the potential causes, and possible resolutions to the issue that you describe.

---

<div class="post-metadata">

**Author:** ![aditya.b](https://avatars.discourse-cdn.com/v4/letter/a/d26b3c/32.png) [@aditya.b](https://discuss.hashicorp.com/u/aditya.b)\
**Post date:** [May 24, 2024, 8:43am UTC](https://discuss.hashicorp.com/t/terraform-plan-detects-false-changes-and-doesnt-show-it-in-the-output/62849/3 "2024-05-24T08:43:21Z")

</div>

Hello, I am also facing an issue like this (I am using the Terraform plugin framework).

In my case, I have one field, named `tags` which is a list of objects of tag, every tag contains string type attributes like id, name, etc.

The problem is, it is being converted to the list of objects and saved into the state and perfectly shows the output when commanded the `terraform state show` but it shows null to the output of the `terraform refresh` command.

the output of the refresh command:

```auto
"tags" = tolist(null) /* of object */

```

the output of the state show command:

```auto
tags = [
        {
            created_at = "2024-05-22T06:31:20.979Z"
            id = "ViT6W8gBDy2tSSXC"
            name = "is a"
            updated_at = "2024-05-22T06:31:20.979Z"
        },
        {
            created_at = "2024-05-22T06:30:35.117Z"
            id = "qdR33oOFHD68qRfV"
            name = "this"
            updated_at = "2024-05-22T06:30:35.117Z"
        },
        {
            created_at = "2024-05-22T06:31:27.427Z"
            id = "sSWEHVjNzDmJ7tEl"
            name = "tags"
            updated_at = "2024-05-22T06:31:27.427Z"
        },
        {
            created_at = "2024-05-22T06:30:31.123Z"
            id = "w3y14sbF579Cr90Z"
            name = "hello"
            updated_at = "2024-05-22T06:30:31.123Z"
        },
    ]

```

---

<div class="post-metadata">

**Author:** ![srpatel](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/srpatel/32/43091_2.png) [@srpatel](https://discuss.hashicorp.com/u/srpatel)\
**Post date:** [November 19, 2024, 7:14am UTC](https://discuss.hashicorp.com/t/terraform-plan-detects-false-changes-and-doesnt-show-it-in-the-output/62849/4 "2024-11-19T07:14:40Z")

</div>

Hello,  
I’m also encountering the same issue. Terraform is attempting to update the attribute `type` when I refresh the plan. I have marked the attribute as `Computed` since its value is determined based on the API response and stored in the state file.

Were you able to find a solution to this issue?
