You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add support for a new `decode_null_to_zero` tag option in JSON struct
tags to decode null and omitted JSON values as zero values instead of
leaving them unset (which usually results in them being set to null).
This is particularly useful for resources where the API does not include
certain optional attributes in responses when they are the default
value. For example, when the API uses Go's `omitempty` or `omitzero`
with a non-pointer type.
In this case, the attribute cannot simply be marked as `Optional`,
because Terraform will complain that the API does not include the
attribute in responses when it is explicitly set to the default value in
a configuration.
Marking the attribute as `Computed` and `Optional` with a `Default` also
does not work without adding the new `decode_null_to_zero` tag, because
Terraform expects the API to always include computed attributes in
responses, which it will not for the default value.
Using the new `decode_null_to_zero` tag solves this issue, since from
Terraform's perspective, the API now always returns a value for the
attribute, even if it is just the default.
0 commit comments