From 5e3a89d70ce21533f6ed5c623f96e1080970eef2 Mon Sep 17 00:00:00 2001 From: Chris Gibson Date: Wed, 11 Jun 2025 13:15:40 +0100 Subject: [PATCH] [GH-29960] Change behaviour for log messages that do not have a valid session (#30014) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Alejandro GarcĂ­a Montoro Co-authored-by: Ben Schumacher --- server/channels/web/handlers.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server/channels/web/handlers.go b/server/channels/web/handlers.go index 6314ce629f..7312b4cd8a 100644 --- a/server/channels/web/handlers.go +++ b/server/channels/web/handlers.go @@ -161,8 +161,8 @@ func (h Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) { mlog.String("url", r.URL.Path), mlog.String("request_id", requestID), } - // if there is a session then include the user_id - if c.AppContext.Session() != nil { + // if there is a valid session and userID then include the user_id + if c.AppContext.Session() != nil && c.AppContext.Session().UserId != "" { responseLogFields = append(responseLogFields, mlog.String("user_id", c.AppContext.Session().UserId)) }