diff --git a/client/recipient.go b/client/recipient.go index c78111f6..eb4723ef 100644 --- a/client/recipient.go +++ b/client/recipient.go @@ -76,7 +76,7 @@ type NotificationRecipientDetails struct { type WebhookPayloads struct { PayloadTemplates PayloadTemplates `json:"payload_templates"` - TemplateVariables []TemplateVariable `json:"template_variables,omitempty"` + TemplateVariables []TemplateVariable `json:"template_variables"` } type PayloadTemplates struct { diff --git a/internal/provider/webhook_recipient_resource.go b/internal/provider/webhook_recipient_resource.go index fd3474a3..5184f124 100644 --- a/internal/provider/webhook_recipient_resource.go +++ b/internal/provider/webhook_recipient_resource.go @@ -298,6 +298,8 @@ func (r *webhookRecipientResource) Update(ctx context.Context, req resource.Upda state.Templates = plan.Templates if rcpt.Details.WebhookPayloads.TemplateVariables != nil { state.Variables = plan.Variables + } else { + state.Variables = types.SetNull(types.ObjectType{AttrTypes: models.TemplateVariableAttrType}) } } else { state.Templates = types.SetNull(types.ObjectType{AttrTypes: models.WebhookTemplateAttrType}) diff --git a/internal/provider/webhook_recipient_resource_test.go b/internal/provider/webhook_recipient_resource_test.go index ae497d13..6f64fb05 100644 --- a/internal/provider/webhook_recipient_resource_test.go +++ b/internal/provider/webhook_recipient_resource_test.go @@ -302,6 +302,82 @@ resource "honeycombio_webhook_recipient" "test" { }) }) + t.Run("custom webhook when a variable is removed", func(t *testing.T) { + name := test.RandomStringWithPrefix("test.", 20) + url := test.RandomURL() + body := `<