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


##########
superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/transformers/filterTransformer.ts:
##########
@@ -67,7 +67,16 @@ function isDividerType(
 function isFormInput(
   formInputs: NativeFilterFormOrSaved,
 ): formInputs is NativeFiltersFormItem {
-  return 'dataset' in formInputs;
+  // Values reaching this transform come either from the modal form
+  // (`NativeFiltersFormItem`) or from the already-saved filter config map
+  // (`Filter`). A saved filter always carries a serialized `targets` array,
+  // while a form item never does. Keying the discriminator off `dataset`
+  // misclassified filter types with no dataset control (e.g. `filter_time`)
+  // as saved filters, so their raw form state was persisted verbatim —
+  // dropping serialized keys such as `targets`, `defaultDataMask`, and
+  // `cascadeParentIds`, and leaking form-only keys such as
+  // `defaultValueQueriesData` and `requiredFirst`.
+  return !('targets' in formInputs);

Review Comment:
   **Suggestion:** Using property presence alone makes legacy or partially 
migrated saved filters without a `targets` field look like form inputs. The 
dashboard metadata schema accepts arbitrary filter dictionaries, so such 
entries can reach this path; they will then be rebuilt by `transformFormInput`, 
replacing the saved object and discarding fields such as `chartsInScope`, 
`tabsInScope`, and any other persisted target-related data. Preserve the 
saved-filter path for legacy entries using an additional saved-filter 
discriminator or normalize missing targets before this check. [api mismatch]
   
   <details>
   <summary><b>Severity Level:</b> Major ⚠️</summary>
   
   ```mdx
   - ❌ Editing legacy filters discards persisted configuration fields.
   - ❌ Filter scope metadata can be lost during dashboard saves.
   - ⚠️ Unknown future filter properties are not preserved.
   ```
   </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=6f255de0fbaa4939874145a651cfa1e3&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=6f255de0fbaa4939874145a651cfa1e3&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
   
   *(Use Cmd/Ctrl + Click for best experience)*
   <details>
   <summary><b>Prompt for AI Agent 🤖 </b></summary>
   
   ```mdx
   This is a comment left during a code review.
   
   **Path:** 
superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/transformers/filterTransformer.ts
   **Line:** 79:79
   **Comment:**
        *Api Mismatch: Using property presence alone makes legacy or partially 
migrated saved filters without a `targets` field look like form inputs. The 
dashboard metadata schema accepts arbitrary filter dictionaries, so such 
entries can reach this path; they will then be rebuilt by `transformFormInput`, 
replacing the saved object and discarding fields such as `chartsInScope`, 
`tabsInScope`, and any other persisted target-related data. Preserve the 
saved-filter path for legacy entries using an additional saved-filter 
discriminator or normalize missing targets before this check.
   
   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%2F42898&comment_hash=975e7bdeb57ed70e8c2e88922316e3f5b2315088ea662a948f2b286f82b082fa&reaction=like'>👍</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F42898&comment_hash=975e7bdeb57ed70e8c2e88922316e3f5b2315088ea662a948f2b286f82b082fa&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