etr2460 commented on a change in pull request #14057:
URL: https://github.com/apache/superset/pull/14057#discussion_r611779463
##########
File path: superset/utils/log.py
##########
@@ -118,12 +118,23 @@ def log_with_context( # pylint: disable=too-many-locals
duration_ms = int(duration.total_seconds() * 1000) if duration else
None
+ # Initial try and grab user_id via flask.g.user
try:
user_id = g.user.get_id()
except Exception as ex: # pylint: disable=broad-except
Review comment:
we don't need `ex` anymore here
##########
File path: superset/utils/log.py
##########
@@ -118,12 +118,23 @@ def log_with_context( # pylint: disable=too-many-locals
duration_ms = int(duration.total_seconds() * 1000) if duration else
None
+ # Initial try and grab user_id via flask.g.user
try:
user_id = g.user.get_id()
except Exception as ex: # pylint: disable=broad-except
- logging.warning(ex)
user_id = None
+ # Whenever a user is not bounded to a session we
+ # need to add them back before logging to capture user_id
+ if user_id is None:
+ try:
+ session = current_app.appbuilder.get_session
+ session.add(g.user)
Review comment:
is this saying that `g.user` might exist, but `g.user.get_id()` would
return null until you bind the user to the session? do we know why this is?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]