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


##########
superset/sql/execution/executor.py:
##########
@@ -101,6 +101,7 @@ def execute_sql_with_cursor(
     log_query_fn: Any | None = None,
     check_stopped_fn: Any | None = None,
     execute_fn: Any | None = None,
+    is_split: bool = True,

Review Comment:
   **Suggestion:** Changing the new `is_split` parameter default to `True` 
breaks backward behavior for existing callers that do not pass it (notably the 
synchronous execution path), so `SQL_QUERY_MUTATOR` no longer runs when 
`MUTATE_AFTER_SPLIT=False`. Keep the old default behavior (or update all 
callers to pass the intended value explicitly) so mutator governance logic is 
not silently skipped. [api mismatch]
   
   <details>
   <summary><b>Severity Level:</b> Critical 🚨</summary>
   
   ```mdx
   - ❌ Database.execute() skips SQL_QUERY_MUTATOR when MUTATE_AFTER_SPLIT=False.
   - ❌ Governance SQL hooks (e.g. SET ROLE) not applied.
   - ⚠️ Tests only guard explicit is_split calls, not default.
   ```
   </details>
   <details>
   <summary><b>Steps of Reproduction ✅ </b></summary>
   
   ```mdx
   1. Configure a SQL mutator and split behavior by setting
   `current_app.config["SQL_QUERY_MUTATOR"]` to a callable and
   `current_app.config["MUTATE_AFTER_SPLIT"] = False`, which are read in
   `Database.mutate_sql_based_on_config` at `superset/models/core.py:705-24`.
   
   2. Trigger a synchronous query execution via `Database.execute(sql, 
options)` on any SQL
   string (single or multi-statement); this method is defined at
   `superset/models/core.py:1368-28` and constructs a 
`SQLExecutor(self).execute(sql,
   options)`.
   
   3. In `SQLExecutor.execute` at `superset/sql/execution/executor.py:10-95`, 
the query is
   prepared and then `_execute_statements(original_script, transformed_script, 
catalog,
   schema, query)` is called without any `is_split` argument, as seen in
   `_execute_statements` at `executor.py:57-101`.
   
   4. `_execute_statements` calls 
`execute_sql_with_cursor(database=self.database,
   cursor=cursor, statements=[stmt.format()...], query=query, 
log_query_fn=self._log_query)`
   at `executor.py:93-101`, which relies on the default `is_split: bool = True` 
in the
   signature at `executor.py:17-26`; inside `execute_sql_with_cursor`, each 
statement is
   passed to `database.mutate_sql_based_on_config(statement, 
is_split=is_split)` at
   `executor.py:66-70`, so `mutate_sql_based_on_config` sees `is_split=True` 
while
   `MUTATE_AFTER_SPLIT=False` (models/core.py:17-24), making the condition 
`is_split ==
   app.config["MUTATE_AFTER_SPLIT"]` false and preventing `SQL_QUERY_MUTATOR` 
from running at
   all for these synchronous calls, unlike prior behavior where the default 
`is_split=False`
   matched `MUTATE_AFTER_SPLIT=False`.
   ```
   </details>
   
   [![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=bdda84373da2486691cab2e69e1ae6ae&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=bdda84373da2486691cab2e69e1ae6ae&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
   
   *(Use Cmd/Ctrl + Click for best experience)*
   <details>
   <summary><b>Prompt for AI Agent 🤖 </b></summary>
   
   ```mdx
   This is a comment left during a code review.
   
   **Path:** superset/sql/execution/executor.py
   **Line:** 104:104
   **Comment:**
        *Api Mismatch: Changing the new `is_split` parameter default to `True` 
breaks backward behavior for existing callers that do not pass it (notably the 
synchronous execution path), so `SQL_QUERY_MUTATOR` no longer runs when 
`MUTATE_AFTER_SPLIT=False`. Keep the old default behavior (or update all 
callers to pass the intended value explicitly) so mutator governance logic is 
not silently skipped.
   
   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%2F41127&comment_hash=cbfc0c1142b692164e5cd73d68e3bdedf123202e67184ef2de123c92485fc798&reaction=like'>👍</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41127&comment_hash=cbfc0c1142b692164e5cd73d68e3bdedf123202e67184ef2de123c92485fc798&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