fix: use descriptive error for unknown block options in health and log plugins (#8128)

This commit is contained in:
Immanuel Tikhonov
2026-05-28 03:29:24 +04:00
committed by GitHub
parent afdf121a5a
commit 0bcb17df06
4 changed files with 29 additions and 12 deletions

View File

@@ -2,6 +2,7 @@ package log
import (
"reflect"
"strings"
"testing"
"github.com/coredns/caddy"
@@ -182,3 +183,14 @@ func TestLogParse(t *testing.T) {
}
}
}
func TestLogParseUnknownProperty(t *testing.T) {
c := caddy.NewTestController("dns", `log { unknown }`)
_, err := logParse(c)
if err == nil {
t.Fatal("expected error for unknown block option, got nil")
}
if !strings.Contains(err.Error(), "unknown property") {
t.Errorf("expected error to contain 'unknown property', got: %v", err)
}
}