aminghadersohi commented on code in PR #45242:
URL: https://github.com/apache/superset/pull/45242#discussion_r4265074565


##########
superset/mcp_service/dashboard/tool/apply_dashboard_filters.py:
##########
@@ -311,6 +637,23 @@ def _timegrain_data_mask(
     }
 
 
+def _verified_select_data_mask(
+    conf: dict[str, Any], values: list[FilterSelectValue]
+) -> tuple[dict[str, Any], list[FilterSelectValue]]:
+    """Build a filter_select data mask from values checked against the data.
+
+    Returns the mask and the values it selects, which may differ from the
+    requested ones where a near match was resolved to the column's value.
+    """
+    # Built first so configuration errors surface before any data is read.
+    data_mask = _select_data_mask(conf, values)
+    if not values:
+        return data_mask, values
+    column = data_mask["extraFormData"]["filters"][0]["col"]
+    values = _verify_select_values(conf, column, values)

Review Comment:
   Yes, confirmed: both `_build_new_filter_config` and `_merge_select_default` 
pass explicit defaults through `_default_data_mask` without checking column 
membership.
   
   I am leaving that shared-config change separate from this per-caller 
permalink fix. A concrete follow-up would extract the validator into a common 
module (apply already imports manage), validate nonempty explicit defaults 
before `UpdateDashboardNativeFiltersCommand`, and preserve empty/first-item 
defaults. It should test add and update operations: unknown/ambiguous defaults 
must not invoke the write command, canonicalized defaults must retain their 
stored JSON types, and empty/first-item behavior must remain unchanged.
   
   Reusing `_verify_select_values` unchanged needs a policy decision: it 
accepts unreadable values unchecked, and its absence check uses the editor’s 
RLS-visible values, not every viewer’s values. Shared defaults need an explicit 
policy for lookup failures and RLS-limited editors. This patch does not change 
default-value validation.



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