omsn2 commented on code in PR #43108:
URL: https://github.com/apache/superset/pull/43108#discussion_r3959471313


##########
superset-frontend/src/dashboard/containers/DashboardPage.tsx:
##########
@@ -226,6 +268,17 @@ export const DashboardPage: FC<PageProps> = ({ idOrSlug }: 
PageProps) => {
         }
       } else if (nativeFilterKeyValue) {
         dataMask = await getFilterValue(id, nativeFilterKeyValue);
+      } else {
+        const savedFilters = getSavedDashboardFilters(id, userId);
+        // Guard against corrupted or unexpected localStorage data shapes
+        // (e.g. a JSON array or primitive) before assigning to dataMask.
+        if (
+          savedFilters &&
+          typeof savedFilters === 'object' &&
+          !Array.isArray(savedFilters)
+        ) {
+          dataMask = savedFilters;

Review Comment:
   I've updated the PR to address your feedback. Instead of just relying on the 
filter ID, the code now saves a lightweight snapshot of the filter definitions 
(specifically the targets and filterType) alongside the dataMask in 
localStorage.
   
   During hydration, if this versioned schema is found, it performs a strict 
validation: it compares the snapshot against the dashboard's current 
native_filter_configuration and silently drops any saved state where the target 
column/dataset or filter type has changed. For backwards compatibility, it 
falls back to the ID-only check if the older (unversioned) schema is found, so 
we don't break existing saved states. But going forward, this establishes the 
exact safety boundary you requested for all newly saved states. Let me know if 
this looks good!



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