Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
bflad opened this issue Dec 20, 2022 · 0 comments
Open
Labels
enhancement New feature or request types Issues and pull requests about our types abstraction and implementations.

Comments

@bflad
Copy link
Contributor

bflad commented Dec 20, 2022

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(), 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:

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 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.

@bflad bflad added the enhancement New feature or request label Dec 20, 2022
@bflad bflad added the types Issues and pull requests about our types abstraction and implementations. label Jan 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request types Issues and pull requests about our types abstraction and implementations.
Projects
None yet
Development

No branches or pull requests

1 participant