mirror of
https://github.com/apache/superset.git
synced 2026-08-04 04:52:32 +00:00
fix(logging): stop noisy LocalProxy-not-mapped warning for guest users (#42306)
Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -28,6 +28,7 @@ from typing import Any, Callable, cast, Literal
|
||||
|
||||
from flask import g, has_request_context, request
|
||||
from flask_appbuilder.const import API_URI_RIS_KEY
|
||||
from sqlalchemy import inspect as sa_inspect
|
||||
from sqlalchemy.exc import SQLAlchemyError
|
||||
|
||||
from superset.extensions import stats_logger_manager
|
||||
@@ -193,11 +194,14 @@ class AbstractEventLogger(ABC):
|
||||
if user_id is None and has_request_context():
|
||||
try:
|
||||
actual_user = g.get("user", None)
|
||||
if actual_user is not None:
|
||||
# Guest/anonymous users (e.g. embedded dashboards) are never
|
||||
# DB-mapped, so adding them to the session always fails.
|
||||
# This is expected and not worth logging.
|
||||
if actual_user is not None and sa_inspect(actual_user, raiseerr=False):
|
||||
db.session.add(actual_user)
|
||||
user_id = get_user_id()
|
||||
except Exception as ex:
|
||||
logging.warning("Failed to add user to db session: %s", ex)
|
||||
logger.debug("Failed to add user to db session: %s", ex)
|
||||
user_id = None
|
||||
payload = collect_request_payload()
|
||||
if object_ref:
|
||||
|
||||
Reference in New Issue
Block a user