bito-code-review[bot] commented on code in PR #42934:
URL: https://github.com/apache/superset/pull/42934#discussion_r3801933870


##########
superset/security/session_invalidation.py:
##########
@@ -187,6 +198,23 @@ def _stamp_existing() -> int:
         _stamp_existing()
 
 
+def invalidate_sessions_for_user(user_id: int) -> None:
+    """Stamp the invalidation epoch for ``user_id`` from ordinary application 
code.
+
+    Convenience wrapper around ``invalidate_user_sessions`` for callers that
+    don't have the raw ``Connection`` the ``after_update`` event listener
+    receives -- e.g. a password-change flow. The stamp is written through the
+    current session's own connection, so it participates in whatever
+    transaction the caller's other pending changes belong to; it is not
+    committed here, so the caller's own commit (or the next flush that
+    triggers one) is what makes it durable.
+    """
+    # pylint: disable=import-outside-toplevel
+    from superset.extensions import db
+
+    invalidate_user_sessions(db.session.connection(), user_id)

Review Comment:
   <div>
   
   
   <div id="suggestion">
   <div id="issue"><b>Missing tests for new public API</b></div>
   <div id="fix">
   
   The new public function `invalidate_sessions_for_user` (line 201) is called 
from at least two production callers (`security/manager.py:458`, 
`views/users/api.py:84`) but has no unit test coverage. Rule 11730 requires 
comprehensive unit tests for new tools; without them the wrapper's delegation 
and non-committing semantics could regress silently.
   </div>
   
   
   </div>
   
   
   
   
   <small><i>Code Review Run #e841f8</i></small>
   </div>
   
   ---
   Should Bito avoid suggestions like this for future reviews? (<a 
href=https://alpha.bito.ai/home/ai-agents/review-rules>Manage Rules</a>)
   - [ ] Yes, avoid them



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