From 63ee6a40d7d30a2747db68e7ef9fcdcc47e97e00 Mon Sep 17 00:00:00 2001 From: Michael Reber Date: Wed, 28 Jan 2026 13:59:53 +0100 Subject: [PATCH] When address is empty we explicitly send an empty detail array to clear any existing items if last IP --- internal/integrations/pfsense.go | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/internal/integrations/pfsense.go b/internal/integrations/pfsense.go index 68fd629..8f4626e 100644 --- a/internal/integrations/pfsense.go +++ b/internal/integrations/pfsense.go @@ -320,8 +320,20 @@ func (p *pfSenseIntegration) updateAlias(client *http.Client, baseURL, apiToken "descr": alias.Descr, "address": alias.Address, } - if len(alias.Detail) > 0 { - patchPayload["detail"] = alias.Detail + // pfSense requires that detail cannot have more items than address + // If address is empty, detail must also be empty + if len(alias.Address) > 0 { + // Only include detail if address has items, and ensure detail length matches address length + detailToSend := alias.Detail + if len(detailToSend) > len(alias.Address) { + // Truncate detail to match address length + detailToSend = detailToSend[:len(alias.Address)] + } + // Always include detail array when address has items (even if empty) to maintain consistency + patchPayload["detail"] = detailToSend + } else { + // When address is empty, explicitly set detail to empty array + patchPayload["detail"] = []string{} } data, err := json.Marshal(patchPayload)