dosubot[bot] commented on issue #30424:
URL: https://github.com/apache/superset/issues/30424#issuecomment-2380286172
<!-- Greeting -->
Hey @fmannhardt! I'm here to help you with any bugs, questions, or
contributions you have in mind. Let's work together to resolve the issue you're
facing.
<!-- Answer -->
The issue you're encountering with the export functionality in Superset
4.1.0RC2, where `datasetId` is used instead of `datasetUuid` in native filter
targets, is due to changes introduced in pull request #26765. This PR moved the
logic for rewriting `datasetId` to `datasetUuid` away from the content
generation path, leading to potential filter corruption when importing
dashboards into instances with existing datasets.
The relevant code snippet that performs this replacement during the export
process is:
```python
# Extract all native filter datasets and replace native
# filter dataset references with uuid
for native_filter in payload.get("metadata", {}).get(
"native_filter_configuration", []
):
for target in native_filter.get("targets", []):
dataset_id = target.pop("datasetId", None)
if dataset_id is not None:
dataset = DatasetDAO.find_by_id(dataset_id)
if dataset:
target["datasetUuid"] = str(dataset.uuid)
if export_related:
yield from ExportDatasetsCommand([dataset_id]).run()
```
During the import process, the `update_id_refs` function converts
`datasetUuid` back to `datasetId`:
```python
# fix native filter references
native_filter_configuration = fixed.get("metadata", {}).get(
"native_filter_configuration", []
)
for native_filter in native_filter_configuration:
targets = native_filter.get("targets", [])
for target in targets:
dataset_uuid = target.pop("datasetUuid", None)
if dataset_uuid:
target["datasetId"] = dataset_info[dataset_uuid]["datasource_id"]
```
Reintroducing the logic for rewriting `datasetId` to `datasetUuid` in the
`_file_content` method, as you suggested, should resolve the issue. This
approach ensures that the dataset references remain consistent and unique
across different instances, preventing filter corruption
<sup>[[1]](https://github.com/apache/superset/blob/master/superset/commands/dashboard/export.py)</sup><sup>[[2]](https://github.com/apache/superset/blob/master/superset/commands/dashboard/importers/v1/utils.py)</sup>.
<!-- Dosu Comment Footer -->
*To continue talking to [Dosu](https://dosu.dev), mention @dosu.*
--
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]