bito-code-review[bot] commented on code in PR #42490:
URL: https://github.com/apache/superset/pull/42490#discussion_r3764579066


##########
superset/mcp_service/chart/tool/update_chart_preview.py:
##########
@@ -102,6 +103,49 @@ def _get_previous_form_data(form_data_key: str) -> 
dict[str, Any] | None:
     return None
 
 
+def _preserve_previous_adhoc_filters(
+    new_form_data: dict[str, Any], previous_form_data: dict[str, Any]
+) -> None:
+    """Preserve cached filters without dropping mapper-generated bindings."""
+    previous_filters = previous_form_data.get("adhoc_filters")
+    if not isinstance(previous_filters, list) or not previous_filters:
+        return
+
+    generated_filters = new_form_data.get("adhoc_filters", [])
+    previous_binding = 
previous_form_data.get(MCP_DASHBOARD_TIME_FILTER_SUBJECT)
+    new_binding = new_form_data.get(MCP_DASHBOARD_TIME_FILTER_SUBJECT)
+    merged_filters = [
+        filter_
+        for filter_ in previous_filters
+        if not (
+            previous_binding
+            and previous_binding != new_binding

Review Comment:
   <div>
   
   
   <div id="suggestion">
   <div id="issue"><b>Edge case drops filters without replacement</b></div>
   <div id="fix">
   
   Edge case bug: when `new_binding` is `None` (new config doesn't generate a 
time filter), the condition evaluates to `True` and drops old TEMPORAL_RANGE 
filters with no replacement. This causes silent data loss. Add `new_binding is 
not None` guard.
   </div>
   
   
   </div>
   
   
   
   
   <small><i>Code Review Run #778e84</i></small>
   </div>
   
   ---
   Should Bito avoid suggestions like this for future reviews? (<a 
href=https://alpha.bito.ai/home/ai-agents/review-rules>Manage Rules</a>)
   - [ ] Yes, avoid them



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