From 00e00f019fca34c7b8b420044a3005e0cd13a5a5 Mon Sep 17 00:00:00 2001 From: Sam Dowell Date: Mon, 16 Jun 2025 10:04:58 -0700 Subject: [PATCH] fix: gracefully handle nil err in Logger This handles the case where a null error is passed into the Logger without causing a null pointer dereference / segfault. There are currently a couple places that invoke this function with a nil error and were resulting in a segfault. --- pkg/logging/logging.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pkg/logging/logging.go b/pkg/logging/logging.go index 72c385b..d5e8bbf 100644 --- a/pkg/logging/logging.go +++ b/pkg/logging/logging.go @@ -57,9 +57,11 @@ func (l *Logger) Error(err error, msg string, kvList ...interface{}) { Args map[string]interface{} }{ Msg: msg, - Err: err.Error(), Args: map[string]interface{}{}, } + if err != nil { + payload.Err = err.Error() + } if len(kvList)%2 != 0 { kvList = append(kvList, "") }