hashicorp / hashicorp/terraform-plugin-framework

Removing a block results in planned for existence but config wants absence.

Open
#603 6 comments 2 reactions 1 assignee Claimed by @bflad View on GitHub
bug
Dominant language
Go
Stars
384
Forks
107
Avg merge
3m
Merged PRs (30d)
1

Description

### Module version
```
github.com/hashicorp/terraform-plugin-framework v1.0.0
github.com/hashicorp/terraform-plugin-go v0.14.2
github.com/hashicorp/terraform-plugin-log v0.7.0
github.com/hashicorp/terraform-plugin-sdk/v2 v2.23.0

```

### Relevant provider source code
I reproduced the issue i'm running into at https://github.com/mvantellingen/terraform-pf-testcase The actual implementation is at https://github.com/labd/terraform-provider-commercetools/pull/328

```go
// Schema defines the schema for the data source.
func (r *orderResource) Schema(_ context.Context, _ resource.SchemaRequest, resp *resource.SchemaResponse) {
resp.Schema = schema.Schema{
Description: "Manages an order.",
Attributes: map[string]schema.Attribute{
"id": schema.StringAttribute{
Description: "Numeric identifier of the order.",
Computed: true,
PlanModifiers: []planmodifier.String{
stringplanmodifier.UseStateForUnknown(),
},
},
},
Blocks: map[string]schema.Block{
"myblock": schema.SingleNestedBlock{
Attributes: map[string]schema.Attribute{
"optional": schema.BoolAttribute{
Optional: true,
},
"optional_int": schema.Int64Attribute{
Optional: true,
},
},
},
},
}
}

```

### Terraform Configuration Files

When I have the following config applied:
```hcl
resource "hashicups_order" "test" {
myblock {
optional = false
optional_int = 10
}
}
```

and then want to remove the `myblock`
```hcl
resource "hashicups_order" "test" {
}
```

### Actual Behavior
```sh
Error: Provider produced invalid plan

Provider "registry.terraform.io/hashicorp/hashicups" planned an invalid value
for hashicups_order.test.myblock: planned for existence but config wants
absence.

This is a bug in the provider, which should be reported in the provider's own
issue tracker
````

### Steps to Reproduce
See https://github.com/mvantellingen/terraform-pf-testcase (run `make testacc`)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.