L4XB commented on code in PR #44347:
URL: https://github.com/apache/superset/pull/44347#discussion_r4302949897


##########
superset/commands/export/models.py:
##########
@@ -104,6 +114,10 @@ def run(
                     seen.add(file_name)
 
     def validate(self) -> None:
-        self._models = self.dao.find_by_ids(self.model_ids)
+        self._models = (
+            self.dao.find_by_ids(self.model_ids, skip_visibility_filter=True)

Review Comment:
   Added in e832160d06: 
`test_dataset_export_leaves_out_a_soft_deleted_dataset_unless_asked`. It 
soft-deletes a readable dataset and checks that 
`list(ExportDatasetsCommand([dataset_id]).run())` raises 
`DatasetNotFoundError`, while `include_deleted=True` exports exactly that 
dataset. If `validate()` drops the flag check and always passes 
`skip_visibility_filter=True`, this test is the one that fails.



##########
superset/commands/chart/export.py:
##########
@@ -55,6 +58,26 @@
 REMOVE_KEYS = ["datasource_type", "datasource_name", "url_params"]
 
 
+def find_chart_dataset(model: Slice) -> SqlaTable | None:
+    """Resolve the dataset a chart is built on, soft-deleted ones included.
+
+    ``Slice.table`` is loaded through the soft-delete visibility filter, so a
+    chart whose dataset sits in the trash resolves to ``None`` even though
+    ``datasource_id`` still points at a row. Exporting such a chart off that
+    ``None`` drops both ``dataset_uuid`` and the ``datasets/`` file, and the
+    resulting bundle is rejected by Superset's own importer with
+    ``{"dataset_uuid": ["Missing data for required field."]}``.
+
+    The lookup keeps the DAO base filter, so a dataset the user may not read
+    stays unreachable here just as it does through the relationship.
+    """
+    if model.table:
+        return model.table
+    if model.datasource_type != DatasourceType.TABLE or model.datasource_id is 
None:

Review Comment:
   Added in e832160d06: 
`test_semantic_view_chart_does_not_bundle_the_table_with_its_id`. It exports a 
`semantic_view` chart whose `datasource_id` matches a readable table, with 
`export_related=True`. It asserts that no `datasets/` or `databases/` file is 
produced and that the chart YAML has no `dataset_uuid`. With the 
`datasource_type != DatasourceType.TABLE` guard removed, this test is the one 
that fails.



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