Skip to content
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

Merged
merged 6 commits into from
Apr 13, 2021
Merged

fix: logs table - user_id is NULL #14057

merged 6 commits into from
Apr 13, 2021

Conversation

hughhhh
Copy link
Member

@hughhhh hughhhh commented Apr 9, 2021

SUMMARY

Fixes #13935

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

TEST PLAN

ADDITIONAL INFORMATION

  • Has associated issue:
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
    • Migration is atomic, supports rollback & is backwards-compatible
    • Confirm DB migration upgrade and downgrade tested
    • Runtime estimates and downtime expectations provided
  • Introduces new feature or API
  • Removes existing feature or API

@hughhhh hughhhh changed the title add user back to session fix: DBlogger for user_id Apr 9, 2021
@hughhhh hughhhh changed the title fix: DBlogger for user_id fix: logs table - user_id is NULL Apr 9, 2021
@codecov
Copy link

codecov bot commented Apr 9, 2021

Codecov Report

Merging #14057 (30cc562) into master (92a6692) will increase coverage by 0.11%.
The diff coverage is 100.00%.

❗ Current head 30cc562 differs from pull request most recent head 070ab98. Consider uploading reports for the commit 070ab98 to get more accurate results
Impacted file tree graph

@@            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              
Flag Coverage Δ
cypress 56.33% <ø> (+0.01%) ⬆️
hive 80.45% <100.00%> (+<0.01%) ⬆️
mysql 80.72% <100.00%> (+<0.01%) ⬆️
postgres 80.75% <100.00%> (?)
presto 80.46% <100.00%> (?)
python 81.32% <100.00%> (+0.20%) ⬆️
sqlite 80.35% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
superset/utils/log.py 93.70% <100.00%> (+0.32%) ⬆️
superset/models/core.py 89.37% <0.00%> (+0.27%) ⬆️
superset/views/base_api.py 98.28% <0.00%> (+0.42%) ⬆️
superset/db_engine_specs/postgres.py 96.80% <0.00%> (+1.06%) ⬆️
superset/connectors/sqla/models.py 89.93% <0.00%> (+1.45%) ⬆️
superset-frontend/src/filters/utils.ts 100.00% <0.00%> (+4.76%) ⬆️
superset/db_engine_specs/presto.py 89.53% <0.00%> (+5.43%) ⬆️
superset/sql_validators/postgres.py 100.00% <0.00%> (+50.00%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 92a6692...070ab98. Read the comment docs.

@pull-request-size pull-request-size bot added size/M and removed size/S labels Apr 11, 2021
@hughhhh hughhhh marked this pull request as ready for review April 11, 2021 22:37
@@ -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
Copy link
Member

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)
Copy link
Member

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?

Copy link
Member Author

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.

Copy link
Member

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

@etr2460
Copy link
Member

etr2460 commented Apr 12, 2021

Looks like there was a bad rebase here @hughhhh

Copy link
Member

@etr2460 etr2460 left a 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

@hughhhh hughhhh merged commit 4b23d0e into master Apr 13, 2021
QAlexBall pushed a commit to QAlexBall/superset that referenced this pull request Dec 29, 2021
* add user back to session

* add test for logging None on exceptions

* fix this updated test

* reformat

* reformat

* Update log.py
@rusackas rusackas deleted the hxgh/fix-log-tbl branch January 30, 2023 19:21
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 1.2.0 labels Mar 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels size/M 🚢 1.2.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Issue with logs table - user_id is NULL
3 participants