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


##########
superset-frontend/src/explore/actions/saveModalActions.ts:
##########
@@ -233,21 +245,69 @@ export const updateSlice =
       new?: boolean;
     },
   ) =>
-  async (dispatch: Dispatch, getState: () => Partial<QueryFormData>) => {
+  async (
+    dispatch: Dispatch,
+    getState: () => Partial<QueryFormData> & {
+      versionHistory?: {
+        chartNormalization?: ChartNormalizationTrackingState | null;
+      };
+    },
+  ) => {
     const { slice_id: sliceId, editors, form_data: formDataFromSlice } = slice;
-    const formData = getState().explore?.form_data;
+    const initialState = getState();
+    const formData = JSON.parse(
+      JSON.stringify(initialState.explore?.form_data ?? {}),
+    ) as QueryFormData;
+    const tracking = initialState.versionHistory?.chartNormalization;
+    const saveAttemptId = nanoid();
+    const matchingExclusions = Object.fromEntries(
+      Object.entries(tracking?.exclusions ?? {}).filter(
+        ([control, transition]) =>
+          !tracking?.invalidatedControls[control] &&
+          Object.hasOwn(formData, control) === transition.to_present &&
+          (!transition.to_present ||
+            JSON.stringify(formData[control]) ===
+              JSON.stringify(transition.to_value)),
+      ),
+    ) as AutomaticNormalizationExclusions;

Review Comment:
   **Suggestion:** The exclusion is matched against the pre-payload `formData`, 
but `getSlicePayload` rewrites adhoc and temporal filters before serializing 
`params`. This can attach metadata whose `to_value` does not match the actual 
params sent to the API, so the backend's exact-match validation rejects it and 
the intended normalization change remains visible. Perform the matching against 
the finalized payload form data or return the transformed form data alongside 
the payload. [api mismatch]
   
   <details>
   <summary><b>Severity Level:</b> Major ⚠️</summary>
   
   ```mdx
   - ⚠️ Adhoc-filter normalization metadata can fail exact matching.
   - ⚠️ Automatic filter changes remain visible in chart history.
   - ⚠️ Affected saves still persist correct chart parameters.
   ```
   </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/explore/actions/saveModalActions.ts
   **Line:** 263:272
   **Comment:**
        *Api Mismatch: The exclusion is matched against the pre-payload 
`formData`, but `getSlicePayload` rewrites adhoc and temporal filters before 
serializing `params`. This can attach metadata whose `to_value` does not match 
the actual params sent to the API, so the backend's exact-match validation 
rejects it and the intended normalization change remains visible. Perform the 
matching against the finalized payload form data or return the transformed form 
data alongside the payload.
   
   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%2F43350&comment_hash=cb8cd79ff16d9de419dfa315d16045c1c785300266966347fef1099392ccbe88&reaction=like'>👍</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F43350&comment_hash=cb8cd79ff16d9de419dfa315d16045c1c785300266966347fef1099392ccbe88&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