-
Notifications
You must be signed in to change notification settings - Fork 14.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: logs table - user_id is NULL #14057
Conversation
Codecov Report
@@ Coverage Diff @@
## master #14057 +/- ##
==========================================
+ Coverage 79.43% 79.55% +0.11%
==========================================
Files 942 942
Lines 47675 47682 +7
Branches 5980 5980
==========================================
+ Hits 37873 37932 +59
+ Misses 9681 9629 -52
Partials 121 121
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
superset/utils/log.py
Outdated
@@ -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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we don't need ex
anymore here
if user_id is None: | ||
try: | ||
session = current_app.appbuilder.get_session | ||
session.add(g.user) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@etr2460 At this point in time the g.user
is available the problem is when we try and grab the user_id
. Not sure boss why get_id() is cause the unbounding session error.
I've been working on this for a week and this is working properly in adding the user back to session and allowing us to query the user_id for logging.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
Looks like there was a bad rebase here @hughhhh |
5d03ddc
to
52564eb
Compare
52564eb
to
b173f85
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
stamping to unblock, but i'd still be quite curious to see if Daniel has any other thoughts
* add user back to session * add test for logging None on exceptions * fix this updated test * reformat * reformat * Update log.py
SUMMARY
Fixes #13935
BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
TEST PLAN
ADDITIONAL INFORMATION