From 39fbcbc59e6f24e3384e5eb644b649693d1acf90 Mon Sep 17 00:00:00 2001 From: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Wed, 21 Oct 2026 15:07:05 -0700 Subject: [PATCH] notification: require enabled for the flat webhook target MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit buildTargets included the flat section whenever an endpoint was set, so a disabled [notification.webhook] block — which the scaffold ships with a placeholder endpoint — would start receiving events as soon as any named target activated the queue. --- weed/notification/webhook/webhook_queue.go | 2 +- .../webhook/webhook_queue_test.go | 28 +++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/weed/notification/webhook/webhook_queue.go b/weed/notification/webhook/webhook_queue.go index a48b8a2aac..fc7c0e3efe 100644 --- a/weed/notification/webhook/webhook_queue.go +++ b/weed/notification/webhook/webhook_queue.go @@ -112,7 +112,7 @@ func namedTargetPrefixes(configuration util.Configuration, prefix string) []stri func buildTargets(configuration util.Configuration, prefix string) ([]*target, error) { var prefixes []string - if configuration.GetBool(prefix+"enabled") || configuration.GetString(prefix+"endpoint") != "" { + if configuration.GetBool(prefix + "enabled") { prefixes = append(prefixes, prefix) } prefixes = append(prefixes, namedTargetPrefixes(configuration, prefix)...) diff --git a/weed/notification/webhook/webhook_queue_test.go b/weed/notification/webhook/webhook_queue_test.go index e33a819442..fe15509959 100644 --- a/weed/notification/webhook/webhook_queue_test.go +++ b/weed/notification/webhook/webhook_queue_test.go @@ -653,3 +653,31 @@ func TestNamedTargets(t *testing.T) { t.Errorf("SendMessage() error = %v", err) } } + +// A disabled flat section keeps no target even when an endpoint is set — +// the scaffold ships exactly that combination, and a named target must not +// reactivate it. +func TestBuildTargetsDisabledFlat(t *testing.T) { + cfg := &mapConfig{values: map[string]interface{}{ + "notification.webhook": map[string]interface{}{ + "enabled": false, + "endpoint": "https://your-server.com/webhook", + "named": map[string]interface{}{ + "enabled": true, + "endpoint": "https://example.com/hook", + }, + }, + "notification.webhook.enabled": false, + "notification.webhook.endpoint": "https://your-server.com/webhook", + "notification.webhook.named.enabled": true, + "notification.webhook.named.endpoint": "https://example.com/hook", + }} + + targets, err := buildTargets(cfg, "notification.webhook.") + if err != nil { + t.Fatalf("buildTargets() error = %v", err) + } + if len(targets) != 1 || targets[0].name != "named" { + t.Fatalf("expected only the named target, got %v", targets) + } +}