The AlertMutingRule SendAlertsOnceMutingPeriodHasEnded currently has the
"omitempty" JSON tag. Because false is the boolean zero value, setting
SendAlertsOnceMutingPeriodHasEnded to false causes the field to be
omitted when marshaled as JSON. Since the API defaults this value to
true, it is not possible to set it to false using the Create or
UpdateAlertMutingRule functions.
Removing the "omitempty" tag will allow users to set this field to
false.
The biggest drawback of this PR is that it changes the behavior of not explicitly setting SendAlertsOnceMutingPeriodHasEnded. Before, if the field was unset, the API would default the value to true. Now, leaving the value unset will result in false being sent to the API server. I think this is a reasonable tradeoff given that it was previously impossible to set the value to false, but let me know if you disagree.
The AlertMutingRule SendAlertsOnceMutingPeriodHasEnded currently has the "omitempty" JSON tag. Because false is the boolean zero value, setting SendAlertsOnceMutingPeriodHasEnded to false causes the field to be omitted when marshaled as JSON. Since the API defaults this value to true, it is not possible to set it to false using the Create or UpdateAlertMutingRule functions.
Removing the "omitempty" tag will allow users to set this field to false.
You can see a reproduction of the bug here https://go.dev/play/p/70cNPv6y7jV
The biggest drawback of this PR is that it changes the behavior of not explicitly setting
SendAlertsOnceMutingPeriodHasEnded
. Before, if the field was unset, the API would default the value to true. Now, leaving the value unset will result infalse
being sent to the API server. I think this is a reasonable tradeoff given that it was previously impossible to set the value to false, but let me know if you disagree.