codeant-ai-for-open-source[bot] commented on code in PR #44653:
URL: https://github.com/apache/superset/pull/44653#discussion_r4132507234


##########
superset/jinja_context.py:
##########
@@ -295,6 +295,11 @@ def current_user_roles(self, add_to_cache_keys: bool = 
True) -> list[str] | None
                 self.cache_key_wrapper(json.dumps(user_roles))
             return user_roles
         except Exception:  # pylint: disable=broad-except
+            # `get_user_roles()` lazy-loads roles from db.session, so a caught
+            # DB error can leave it in "pending rollback" state. This runs
+            # during SQL templating, upstream of the engine build that would
+            # otherwise inherit the failed transaction.
+            db.session.rollback()  # pylint: disable=consider-using-transaction

Review Comment:
   ✅ **CodeAnt verified this suggestion was addressed in subsequent commits and 
marked this thread resolved** as of `13bf93a`.
   
   The SQLAlchemy-specific handler rolls back only after database errors, while 
cache-key and other non-database exceptions are handled separately without 
rolling back the shared session.
   
   <sub>If that's not right, unresolve this thread and CodeAnt will leave it 
open.</sub>
   
   <!-- codeant-auto-resolve-reply -->



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