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


##########
superset/common/query_context_processor.py:
##########
@@ -206,6 +207,11 @@ def _resolve_forced_query(
                 self._force_marker_key(nonce, cache_key)
             )
         except Exception:  # noqa: BLE001  pylint: disable=broad-except
+            # Under `SupersetMetastoreCache` this read is a metadata-DB SELECT,
+            # so roll back before degrading to "absent": this runs before any
+            # engine is built, and leaving db.session in "pending rollback"
+            # state would fail the recompute we are about to force.
+            db.session.rollback()  # pylint: disable=consider-using-transaction

Review Comment:
   **Suggestion:** A non-database marker read failure, such as deserialization, 
triggers rollback and can discard unrelated pending metadata changes before 
recomputation.
   
   **Assessment:** ๐ŸŸ  `Major` ยท ๐Ÿ” `Occurrence: Rarely` ยท ๐Ÿท๏ธ `Cache`
   
   [![Use CodeAnt 
Skill](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/use-codeant-skill-flat-v2.svg)](https://docs.codeant.ai/cli/resolve-pr-comments-skill)
 [![Fix in 
Cursor](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-cursor-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=b2933dae52ce44d080281511548cc8b9&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
 [![Fix in VSCode 
Claude](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-vscode-claude-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=b2933dae52ce44d080281511548cc8b9&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
   <details>
   <summary><b>Prompt for AI Agent ๐Ÿค– </b></summary>
   
   ```mdx
   This is a comment left during a code review.
   
   **Path:** superset/common/query_context_processor.py
   **Line:** 214:214
   **Comment:**
        *Cache: A non-database marker read failure, such as deserialization, 
triggers rollback and can discard unrelated pending metadata changes before 
recomputation.
   
   Validate the correctness of the flagged issue. If correct, How can I resolve 
this? If you propose a fix, implement it and please make it concise.
   Once fix is implemented, also check other comments on the same PR, and ask 
user if the user wants to fix the rest of the comments as well. if said yes, 
then fetch all the comments validate the correctness and implement a minimal fix
   ```
   </details>
   <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F44653&comment_hash=27f7a89083189784b1bc2763d97da8aee8e089e0f2d3bca2bfee4a62ac5427a2&reaction=like'>๐Ÿ‘</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F44653&comment_hash=27f7a89083189784b1bc2763d97da8aee8e089e0f2d3bca2bfee4a62ac5427a2&reaction=dislike'>๐Ÿ‘Ž</a>



##########
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:
   **Suggestion:** An exception from cache-key construction, not only database 
access, rolls back the shared session and can erase unrelated pending metadata 
changes.
   
   **Assessment:** ๐ŸŸ  `Major` ยท ๐Ÿ” `Occurrence: Rarely` ยท ๐Ÿท๏ธ `Possible bug`
   
   [![Use CodeAnt 
Skill](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/use-codeant-skill-flat-v2.svg)](https://docs.codeant.ai/cli/resolve-pr-comments-skill)
 [![Fix in 
Cursor](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-cursor-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=809aa9e51dfd41c981caf5a7298672e6&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
 [![Fix in VSCode 
Claude](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-vscode-claude-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=809aa9e51dfd41c981caf5a7298672e6&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
   <details>
   <summary><b>Prompt for AI Agent ๐Ÿค– </b></summary>
   
   ```mdx
   This is a comment left during a code review.
   
   **Path:** superset/jinja_context.py
   **Line:** 302:302
   **Comment:**
        *Possible Bug: An exception from cache-key construction, not only 
database access, rolls back the shared session and can erase unrelated pending 
metadata changes.
   
   Validate the correctness of the flagged issue. If correct, How can I resolve 
this? If you propose a fix, implement it and please make it concise.
   Once fix is implemented, also check other comments on the same PR, and ask 
user if the user wants to fix the rest of the comments as well. if said yes, 
then fetch all the comments validate the correctness and implement a minimal fix
   ```
   </details>
   <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F44653&comment_hash=57dedd520dd816f05b8006ff36a671bdbc44e6ba748769989b1b390cea458f31&reaction=like'>๐Ÿ‘</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F44653&comment_hash=57dedd520dd816f05b8006ff36a671bdbc44e6ba748769989b1b390cea458f31&reaction=dislike'>๐Ÿ‘Ž</a>



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