korbit-ai[bot] commented on code in PR #34765:
URL: https://github.com/apache/superset/pull/34765#discussion_r2286187054


##########
superset-frontend/src/SqlLab/components/SaveQuery/index.tsx:
##########
@@ -147,14 +147,14 @@ const SaveQuery = ({
 
   const close = () => setShowSave(false);
 
-  const onSaveWrapper = () => {
+  const onSaveWrapper = async () => {
     logAction(LOG_ACTIONS_SQLLAB_SAVE_QUERY, {});
-    onSave(queryPayload(), query.id);
+    await onSave(queryPayload(), query.id);

Review Comment:
   ### Inconsistent Payload Generation <sub>![category 
Functionality](https://img.shields.io/badge/Functionality-0284c7)</sub>
   
   <details>
     <summary>Tell me more</summary>
   
   ###### What is the issue?
   The queryPayload() function is called inside the onSave call, which means 
its value could change between retries if there are errors.
   
   
   ###### Why this matters
   Inconsistent payload data could be sent in case of retries, potentially 
leading to data integrity issues.
   
   ###### Suggested change ∙ *Feature Preview*
   Cache the payload before the save operation:
   ```typescript
   const onSaveWrapper = async () => {
     try {
       const payload = queryPayload();
       logAction(LOG_ACTIONS_SQLLAB_SAVE_QUERY, {});
       await onSave(payload, query.id);
       close();
     } catch (error) {
       // Handle error appropriately
     }
   };
   ```
   
   
   ###### Provide feedback to improve future suggestions
   [![Nice 
Catch](https://img.shields.io/badge/👍%20Nice%20Catch-71BC78)](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/3bba0ad2-11e6-4893-990d-f372e80b7995/upvote)
 
[![Incorrect](https://img.shields.io/badge/👎%20Incorrect-white)](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/3bba0ad2-11e6-4893-990d-f372e80b7995?what_not_true=true)
  [![Not in 
Scope](https://img.shields.io/badge/👎%20Out%20of%20PR%20scope-white)](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/3bba0ad2-11e6-4893-990d-f372e80b7995?what_out_of_scope=true)
 [![Not in coding 
standard](https://img.shields.io/badge/👎%20Not%20in%20our%20standards-white)](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/3bba0ad2-11e6-4893-990d-f372e80b7995?what_not_in_standard=true)
 
[![Other](https://img.shields.io/badge/👎%20Other-white)](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/3bba0ad2-11e6-4893-990d-f372e80b7995)
   </details>
   
   <sub>
   
   💬 Looking for more details? Reply to this comment to chat with Korbit.
   </sub>
   
   <!--- korbi internal id:4f0139fe-6704-48c3-b70a-3d00f611f235 -->
   
   
   [](4f0139fe-6704-48c3-b70a-3d00f611f235)



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