bito-code-review[bot] commented on PR #42306:
URL: https://github.com/apache/superset/pull/42306#issuecomment-5066095036

   <!-- Bito Reply -->
   The flagged issue is correct. In Flask-AppBuilder, `g.user` is often a 
`LocalProxy`, and calling `sa_inspect` directly on it can fail to identify the 
underlying mapped model, causing the session rebind to be skipped. To resolve 
this, you should unwrap the proxy using `_get_current_object()` before 
inspection.
   
   Here is the corrected implementation for `superset/utils/log.py`:
   
   ```python
                   actual_user = g.get("user", None)
                   # Unwrap LocalProxy to get the underlying object
                   if hasattr(actual_user, "_get_current_object"):
                       actual_user = actual_user._get_current_object()
                   if actual_user is not None and sa_inspect(actual_user, 
raiseerr=False):
                       db.session.add(actual_user)
                       user_id = get_user_id()
   ```
   
   There are no other review comments in this PR to address.
   
   **superset/utils/log.py**
   ```
   actual_user = g.get("user", None)
                   # Unwrap LocalProxy to get the underlying object
                   if hasattr(actual_user, "_get_current_object"):
                       actual_user = actual_user._get_current_object()
                   if actual_user is not None and sa_inspect(actual_user, 
raiseerr=False):
                       db.session.add(actual_user)
                       user_id = get_user_id()
   ```


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

To unsubscribe, e-mail: [email protected]

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