[GH-29960] Change behaviour for log messages that do not have a valid session (#30014)

Co-authored-by: Alejandro García Montoro <alejandro.garciamontoro@gmail.com>
Co-authored-by: Ben Schumacher <ben.schumacher@mattermost.com>
This commit is contained in:
Chris Gibson
2025-06-11 14:15:40 +02:00
committed by GitHub
co-authored by Alejandro García Montoro Ben Schumacher
parent fcce46655a
commit 5e3a89d70c
+2 -2
View File
@@ -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))
}