Empty value for a block or a map in `forProvider` causes a panic
- Dominant language
- Go
- Stars
- 481
- Forks
- 131
- Avg merge
- 2d 1h
- Merged PRs (30d)
- 11
Description
### What happened?
[Preparing the diff plan response will cause a panic](https://github.com/crossplane/upjet/blob/v1.4.1/pkg/controller/external_tfpluginfw.go#L282), if the `diff.Value1` for a path is `nil`.
### How can we reproduce it?
1. Apply a resource with non-empty values for block or map fields.
2. Updating the resource with empty values such as `[]` and `{}` will cause a panic.
This is most likely related to the way the diff in `terraform-plugin-go` seems to work, but also how the library handles empty values when marshaling to msgpack.
Using a forked version of `upjet` repo with a small change made to the [external_tfpluginfw.go:282](https://github.com/crossplane/upjet/blob/v1.4.1/pkg/controller/external_tfpluginfw.go#L282) seems to mitigate the issue:
```go
if diff.Value1 != nil && diff.Value1.IsKnown() && !diff.Value1.IsNull() {
```
In addition, deleting the resource with also cause some troubles, if the field with the empty value is marked as required.
Related `omitempty` issue: https://github.com/crossplane-contrib/provider-upjet-aws/issues/1357
Contributor guide
Assessment
This issue has not been assessed yet.