etr2460 commented on a change in pull request #14057:
URL: https://github.com/apache/superset/pull/14057#discussion_r611970485



##########
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:
       weird.... @dpgaspar do you have any ideas why this might happen?
   
   If this is the only way to fix it, it's probably fine, but this was pretty 
confusing to me




-- 
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]

Reply via email to