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


##########
superset/views/sql_lab/views.py:
##########
@@ -153,7 +175,23 @@ def put(self, tab_state_id: int) -> FlaskResponse:
             return Response(status=403)
 
         try:
-            fields = {k: json.loads(v) for k, v in 
request.form.to_dict().items()}
+            fields = {
+                k: json.loads(v)
+                for k, v in request.form.to_dict().items()
+                if k in _TAB_STATE_PUT_FIELDS
+            }

Review Comment:
   **Suggestion:** Decoding `extra_json` turns the JSON string into a 
dictionary, but `extra_json` is a text column, so the database update fails 
when the editor sends this field. [type error]
   
   **Assessment:** ๐ŸŸ  `Major` ยท ๐Ÿ” `Occurrence: Often`
   
   [![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=8531438af071455aa0acd40eef52dd22&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=8531438af071455aa0acd40eef52dd22&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/views/sql_lab/views.py
   **Line:** 178:182
   **Comment:**
        *Type Error: Decoding `extra_json` turns the JSON string into a 
dictionary, but `extra_json` is a text column, so the database update fails 
when the editor sends this field.
   
   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%2F43992&comment_hash=d5db8f2102be1e349e92a0e2f23fc0dd0a561267b03ae63b854420a2307369c6&reaction=like'>๐Ÿ‘</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F43992&comment_hash=d5db8f2102be1e349e92a0e2f23fc0dd0a561267b03ae63b854420a2307369c6&reaction=dislike'>๐Ÿ‘Ž</a>



##########
superset/views/sql_lab/views.py:
##########
@@ -172,9 +210,10 @@ def migrate_query(self, tab_state_id: int) -> 
FlaskResponse:
                 return Response(status=403)
 
             client_id = json.loads(request.form["queryId"])
-            db.session.query(Query).filter_by(client_id=client_id).update(
-                {"sql_editor_id": tab_state_id}
-            )
+            db.session.query(Query).filter(
+                Query.client_id == client_id,
+                or_(Query.user_id == get_user_id(), Query.user_id.is_(None)),
+            ).update({"sql_editor_id": tab_state_id})

Review Comment:
   **Suggestion:** A foreign or stale query matches zero rows, but the endpoint 
still returns success, causing `migrateQuery` to update frontend state even 
though the backend association did not change. [api mismatch]
   
   **Assessment:** ๐ŸŸ  `Major` ยท ๐Ÿ” `Occurrence: Sometimes`
   
   [![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=b7268648aa924635a63c55f4bc88ebbf&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=b7268648aa924635a63c55f4bc88ebbf&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/views/sql_lab/views.py
   **Line:** 213:216
   **Comment:**
        *Api Mismatch: A foreign or stale query matches zero rows, but the 
endpoint still returns success, causing `migrateQuery` to update frontend state 
even though the backend association did not change.
   
   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%2F43992&comment_hash=a1a237aeeebee62c65b9f78f45ed0ce214346cab82d29c5ac538252dc3a70910&reaction=like'>๐Ÿ‘</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F43992&comment_hash=a1a237aeeebee62c65b9f78f45ed0ce214346cab82d29c5ac538252dc3a70910&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