Alerting: Workaround for bad handling of empty strings in contact points API #656
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The Terraform default is to use empty-strings for blank or missing fields. This is consistent with a lot of Go-based clients, but Terraform is very aggressive with this. In fact, in many cases the provider API has no way of telling whether a field was missing from HCL entirely, or present with an empty string: hashicorp/terraform-plugin-sdk#741
This is normally fine, assuming that the underlying API is well behaved. Most of Grafana's API handle this well, but the
settings
field in contact points do not handle this consistently. Empty strings circumvent the API validation entirely. See this issue in Grafana: grafana/grafana#55139This issue in Grafana will take quite some time to fix. This PR implements a much faster workaround in the provider. This allows us to get a workaround released to users faster, while we fix the main bug in the Grafana API. This also means the provider will continue to work with Grafana versions affected by the above issue, which is nice for compatibility.
We will now treat this settings blob as if it's a struct with all fields being
omitempty
. Empty settings values will simply not be sent to the server at all.