From 932dac157a3c4693b80576477498bb86208b9b30 Mon Sep 17 00:00:00 2001
From: Matthew Holt <mholt@users.noreply.github.com>
Date: Fri, 7 Feb 2025 06:18:34 -0700
Subject: [PATCH] logging: Always set fields func; fix #6829

---
 modules/caddyhttp/logging.go | 1 +
 1 file changed, 1 insertion(+)

diff --git a/modules/caddyhttp/logging.go b/modules/caddyhttp/logging.go
index 87298ac3c..cef9ea139 100644
--- a/modules/caddyhttp/logging.go
+++ b/modules/caddyhttp/logging.go
@@ -195,6 +195,7 @@ func (sa *StringArray) UnmarshalJSON(b []byte) error {
 // have richer information.
 func errLogValues(err error) (status int, msg string, fields func() []zapcore.Field) {
 	var handlerErr HandlerError
+	fields = func() []zapcore.Field { return []zapcore.Field{} } // don't be nil (fix #6829)
 	if errors.As(err, &handlerErr) {
 		status = handlerErr.StatusCode
 		if handlerErr.Err == nil {