[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>
Этот коммит содержится в:
Chris Gibson
2025-06-11 13:15:40 +01:00
коммит произвёл GitHub
родитель fcce46655a
Коммит 5e3a89d70c

Просмотреть файл

@@ -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))
}