hashicorp / hashicorp/terraform-plugin-sdk

GetOkExists broken with schema.TypeSet

Open
#115 1 comment 0 reactions 0 assignees View on GitHub
bug subsystem/types terraform-plugin-framework
Dominant language
Go
Stars
485
Forks
244
Avg merge
19h 57m
Merged PRs (30d)
4

Description

GetOkExists seems to have some cases which it returns a false positive, specifically when dealing with properties within a nested object with the type: schema.TypeSet.

In the example below within the nested object "backend", the only property which is explicitly set is "max_connections_per_instance", however schema.ResourceData.GetOkExists() is returning true on all the other properties within the nested object's schema: https://github.com/terraform-providers/terraform-provider-google/blob/96b17536b9f6152ca9b421a665c5ac56bc673280/google/resource_compute_backend_service.go#L67

This is causing breaking behavior when fields which weren't set by the user are being sent across to the wire inappropriately, causing the backend API to return an error in some use cases. We're currently having to work around this issue by implementing client side logic which proactively filters out these properties in such use cases and diff suppressing these properties from TF state. This is problematic as it obfuscates scenarios wherein users are incorrectly setting these values, but aren't being informed of their incorrect configs due to the client side filtering.

### Terraform Version
```hcl
0.11.7
```
### Terraform Configuration Files

```hcl
resource "google_compute_backend_service" "testservice" {
name = "```"
description = "Hello World 1234"
port_name = "http"
protocol = "TCP"

backend {
group = "${google_compute_instance_group_manager.foobar.instance_group}"
max_connections_per_instance = 20
}

health_checks = ["${google_compute_health_check.default.self_link}"]
}
```

### Debug Output

### Crash Output

### Expected Behavior

### Actual Behavior

### Steps to Reproduce

### Additional Context

### References

Contributor guide

Open the contributing guide

Research direction

Start by reading ResourceData.GetOkExists and the schema.TypeSet handling, using google/resource_compute_backend_service.go as the reported reproduction point. Confirm the nested backend properties that were not configured are not reported as present, and add a regression test covering the described configuration.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.