hashicorp / hashicorp/terraform-plugin-framework
tfsdk: Allow GetAttribute To Return Unknown Values Instead Of Null When Missing Due To Parent Being Unknown
- Dominant language
- Go
- Stars
- 384
- Forks
- 107
- Avg merge
- 3m
- Merged PRs (30d)
- 1
Description
### Module version
```
v0.4.2
```
### Use-cases
As part of fixing #150, the `GetAttribute()` method on `Config`, `Plan`, and `State` will skip `tftypes.ErrInvalidStep` errors and instead return null values when valid, but missing. A related case of this behavior that might be useful for functionality such as plan modifiers and validation is knowing whether the value is instead unknown, which can happen if the value is missing from `Config`, `Plan`, or `State` because a parent path value is marked as unknown.
### Attempted Solutions
Providers can verify if any parent paths are unknown, when a null value is returned. For example in attribute plan modifiers, the entire `Config`, `Plan`, or `State` value is available.
### Proposal
Have the `GetAttribute()` method on `Config`, `Plan`, and `State` automatically perform the parent path checks for unknown. If found, return unknown value for type, otherwise continue returning null value for type.
### References
- #150
- #185
Contributor guide
Assessment
This issue has not been assessed yet.