hashicorp / hashicorp/terraform-plugin-framework

types: Consider Method for Checking Whether Collection Values are Fully Known

Open
#597 0 comments 0 reactions 0 assignees View on GitHub
enhancement types
Dominant language
Go
Stars
384
Forks
107
Avg merge
3m
Merged PRs (30d)
1

Description

### Module version

```
v1.0.1
```

### Use-cases

Configuration validation logic generally needs to skip over any potentially unknown values. The `IsUnknown() bool` method checks whether the value itself is unknown, but in the case of collection types such as `List`, `Map`, `Object`, and `Set` there may be underlying attributes/elements which are unknown. For validators such as the terraform-plugin-framework-validators [`listvalidator.UniqueValues()`](https://pkg.go.dev/github.com/hashicorp/terraform-plugin-framework-validators@v0.9.0/listvalidator#UniqueValues), it tries to detect duplicate values in the list based on value type equality. If there are unknown values from differing sources, it may unexpectedly trip up the equality checking since there is no differentiation in the type system between unknown values. For example:

```terraform
resource "examplecloud_thing" "example" {
count = 2
}

resource "examplecloud_widget" "example" {
thing_ids = [for id in examplecloud_thing[*].id: id] # differing unknown strings
}
```

### Proposal

Upstream in terraform-plugin-go, the [`tftypes.Value.IsFullyKnown() bool` method](https://pkg.go.dev/github.com/hashicorp/terraform-plugin-go@v0.14.2/tftypes#Value.IsFullyKnown) provides additional recursive checks about whether the value contains unknown values. This module could provide something similar for all the framework types or at least the collection types. The implementation may need to lean on using the `*Valuable` interfaces to handle custom types.

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.