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


##########
superset-frontend/src/SqlLab/components/SaveQuery/index.tsx:
##########
@@ -111,6 +113,13 @@ const SaveQuery = ({
   const [label, setLabel] = useState<string>(defaultLabel);
   const [showSave, setShowSave] = useState<boolean>(false);
   const [showSaveDatasetModal, setShowSaveDatasetModal] = useState(false);
+  // Saving a dataset runs the SQL to introspect columns, so it needs a
+  // successful run first -- same check that gates "Schedule query".
+  const latestQueryState = useSelector<SqlLabRootState, string>(
+    ({ sqlLab }) =>
+      sqlLab.queries[queryEditor.latestQueryId || '']?.state || '',

Review Comment:
   **Suggestion:** The success check follows only `latestQueryId`, which 
remains pointed at the previous successful query when the editor SQL is 
changed. This leaves the dataset button enabled and allows `SaveDatasetModal` 
to submit newly edited, unexecuted SQL, defeating the required gate. Invalidate 
the successful-run state when SQL changes or verify that the stored successful 
query's SQL matches the current editor SQL before enabling the button. [stale 
reference]
   
   <details>
   <summary><b>Severity Level:</b> Major ⚠️</summary>
   
   ```mdx
   - ❌ Dataset saving can submit SQL that was never successfully run.
   - ⚠️ The intended run-before-save safeguard is bypassed after edits.
   - ⚠️ Users may receive save-time validation errors for untested SQL.
   ```
   </details>
   
   [![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)
   <details>
   <summary><b>Prompt for AI Agent 🤖 </b></summary>
   
   ```mdx
   This is a comment left during a code review.
   
   **Path:** superset-frontend/src/SqlLab/components/SaveQuery/index.tsx
   **Line:** 118:120
   **Comment:**
        *Stale Reference: The success check follows only `latestQueryId`, which 
remains pointed at the previous successful query when the editor SQL is 
changed. This leaves the dataset button enabled and allows `SaveDatasetModal` 
to submit newly edited, unexecuted SQL, defeating the required gate. Invalidate 
the successful-run state when SQL changes or verify that the stored successful 
query's SQL matches the current editor SQL before enabling the button.
   
   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%2F43334&comment_hash=a6b56ee8480df05f58cddede14d7e7392c3d86df7294957189bfee7ddf5d3f3b&reaction=like'>👍</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F43334&comment_hash=a6b56ee8480df05f58cddede14d7e7392c3d86df7294957189bfee7ddf5d3f3b&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