From b657ffa496bf198c1914a022b8028335237e7e78 Mon Sep 17 00:00:00 2001 From: Anis Eleuch Date: Thu, 21 Mar 2024 18:19:36 +0100 Subject: [PATCH] fix: Fix crash when logging events and anonymous is enabled (#19313) Events log does not have a stacktrace. So Trace is nil. Fix a crash in this case when an event is printed while anonymous logging is enabled. --- internal/logger/logger.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/internal/logger/logger.go b/internal/logger/logger.go index 3ef2f8fb1..bb02f80d0 100644 --- a/internal/logger/logger.go +++ b/internal/logger/logger.go @@ -364,7 +364,9 @@ func buildLogEntry(ctx context.Context, message string, trace []string, errKind entry.API.Args.Bucket = HashString(entry.API.Args.Bucket) entry.API.Args.Object = HashString(entry.API.Args.Object) entry.RemoteHost = HashString(entry.RemoteHost) - entry.Trace.Variables = make(map[string]interface{}) + if entry.Trace != nil { + entry.Trace.Variables = make(map[string]interface{}) + } } return entry