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


##########
superset-frontend/src/dashboard/actions/nativeFilters.ts:
##########
@@ -90,12 +90,20 @@ export const setFilterConfiguration =
     });
     try {
       const response = await updateFilters(filterChanges);
+      // chartsInScope/tabsInScope are derived from the live layout, and the
+      // response carries the persisted copy for every filter - including the
+      // ones this save never touched, whose copy is whatever was stored when
+      // the dashboard was last saved. Dropping them lets the reducers keep the
+      // scopes calculateScopes already computed for this session.
+      const savedFilters = response.result.map(
+        filter => omit(filter, ['chartsInScope', 'tabsInScope']) as Filter,
+      );
       dispatch({
         type: SET_NATIVE_FILTERS_CONFIG_COMPLETE,
-        filterChanges: response.result,
+        filterChanges: savedFilters,
         deletedIds: filterChanges.deleted,
       });
-      dispatch(nativeFiltersConfigChanged(response.result));
+      dispatch(nativeFiltersConfigChanged(savedFilters));

Review Comment:
   **Suggestion:** Dispatching the entire response into dashboard metadata 
allows an older concurrent PUT response to overwrite a newer local filter 
configuration. If two saves are issued before the first completes and the 
responses arrive out of order, the stale `savedFilters` array replaces the 
newer metadata, reverting filter edits and scopes. Track request generations 
and ignore stale responses, or merge the response only into the still-current 
filter state. [race condition]
   
   <details>
   <summary><b>Severity Level:</b> Major ⚠️</summary>
   
   ```mdx
   - ⚠️ Rapid successive filter saves can revert newer configuration changes.
   - ⚠️ Dashboard metadata can disagree with active native-filter state.
   - ⚠️ Older responses can restore stale filter ordering, properties, or 
scopes.
   ```
   </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=0ef9ace88a6c447284d9af4caa6464e9&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=0ef9ace88a6c447284d9af4caa6464e9&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-frontend/src/dashboard/actions/nativeFilters.ts
   **Line:** 106:106
   **Comment:**
        *Race Condition: Dispatching the entire response into dashboard 
metadata allows an older concurrent PUT response to overwrite a newer local 
filter configuration. If two saves are issued before the first completes and 
the responses arrive out of order, the stale `savedFilters` array replaces the 
newer metadata, reverting filter edits and scopes. Track request generations 
and ignore stale responses, or merge the response only into the still-current 
filter state.
   
   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%2F43252&comment_hash=ed3e76ca4a5bb027b5c0f4915ec58bd194ac5a639682dd98c09f320a4dc4ae76&reaction=like'>👍</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F43252&comment_hash=ed3e76ca4a5bb027b5c0f4915ec58bd194ac5a639682dd98c09f320a4dc4ae76&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