korbit-ai[bot] commented on code in PR #33364:
URL: https://github.com/apache/superset/pull/33364#discussion_r2073755750
##########
superset/viz.py:
##########
@@ -1532,7 +1532,31 @@ def get_data(self, df: pd.DataFrame) -> VizData:
slice_ids = self.form_data.get("deck_slices")
slices = db.session.query(Slice).filter(Slice.id.in_(slice_ids)).all()
+
+ features: dict[str, list[Any]] = {}
+
+ for slc in slices:
+ form_data = slc.form_data
+
+ form_data["extra_filters"] = self.form_data.get("extra_filters",
[])
+ form_data["extra_form_data"] =
self.form_data.get("extra_form_data", {})
+ form_data["adhoc_filters"] = self.form_data.get("adhoc_filters")
Review Comment:
### Shared Filter Object Reference Across Slices <sub></sub>
<details>
<summary>Tell me more</summary>
###### What is the issue?
The filters from the parent visualization are directly assigned to each
slice's form_data without creating a deep copy, which could lead to unintended
modifications of shared filter objects across slices.
###### Why this matters
If multiple slices process these filters simultaneously, they could
interfere with each other's filter state since they're referencing the same
object in memory.
###### Suggested change ∙ *Feature Preview*
Create deep copies of the filter objects before assigning them to each
slice's form_data:
```python
for slc in slices:
form_data = slc.form_data
form_data["extra_filters"] =
copy.deepcopy(self.form_data.get("extra_filters", []))
form_data["extra_form_data"] =
copy.deepcopy(self.form_data.get("extra_form_data", {}))
form_data["adhoc_filters"] =
copy.deepcopy(self.form_data.get("adhoc_filters"))
```
###### Provide feedback to improve future suggestions
[](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/8db33baf-4361-4c16-8fd9-462ea2c96b7f/upvote)
[](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/8db33baf-4361-4c16-8fd9-462ea2c96b7f?what_not_true=true)
[](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/8db33baf-4361-4c16-8fd9-462ea2c96b7f?what_out_of_scope=true)
[](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/8db33baf-4361-4c16-8fd9-462ea2c96b7f?what_not_in_standard=true)
[](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/8db33baf-4361-4c16-8fd9-462ea2c96b7f)
</details>
<sub>
💬 Looking for more details? Reply to this comment to chat with Korbit.
</sub>
<!--- korbi internal id:f96bc113-cdb3-4d82-90e0-5e585e674a47 -->
[](f96bc113-cdb3-4d82-90e0-5e585e674a47)
--
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]