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


##########
superset/commands/chart/importers/v1/utils.py:
##########
@@ -48,20 +48,86 @@ def import_chart(
     overwrite: bool = False,
     ignore_permissions: bool = False,
 ) -> Slice:
+    """Import a chart from a config dict, handling existing matches.
+
+    Permission model for an existing UUID match:
+
+    +--------------+---------------+---------------------+-----------------+
+    | Existing row | overwrite arg | Caller has perms?   | Outcome         |
+    +==============+===============+=====================+=================+
+    | alive        | False         | (n/a)               | return existing |
+    +--------------+---------------+---------------------+-----------------+
+    | alive        | True          | can_write + owner   | UPDATE in place |
+    +--------------+---------------+---------------------+-----------------+
+    | alive        | True          | can_write,          | raise           |
+    |              |               | not owner/admin     |                 |
+    +--------------+---------------+---------------------+-----------------+
+    | soft-deleted | False or True | can_write + owner   | restore + UPDATE|
+    +--------------+---------------+---------------------+-----------------+
+    | soft-deleted | False or True | can_write,          | raise           |
+    |              |               | not owner/admin     |                 |
+    +--------------+---------------+---------------------+-----------------+
+    | soft-deleted | False or True | not can_write       | raise (Case B)  |
+    +--------------+---------------+---------------------+-----------------+
+
+    Re-importing a soft-deleted UUID is implicitly a restore-with-update:
+    the user is bringing the chart back by uploading it again. We apply
+    the same ownership check as the explicit overwrite path so non-owners
+    cannot resurrect via re-import, and we raise rather than silently
+    returning a soft-deleted row to callers without write permission
+    (which would let them reattach dashboards to a deleted chart).
+    """
     can_write = ignore_permissions or security_manager.can_access("can_write", 
"Chart")
-    existing = db.session.query(Slice).filter_by(uuid=config["uuid"]).first()
+    from superset.commands.importers.v1.utils import find_existing_for_import

Review Comment:
   **BLOCKER — inline import without circular-import justification (Scan 1, 
Rule 6)**
   
   `from superset.commands.importers.v1.utils import find_existing_for_import` 
is placed inside the function body with no comment.
   
   I traced the full import chain: `superset.commands.importers.v1.utils` 
imports only `superset.{db, models.core, models.dashboard, models.helpers, 
tags.models, utils, commands.importers.exceptions, databases.ssh_tunnel.models, 
extensions}` — none of which import from 
`superset.commands.chart.importers.v1.utils`. **No cycle exists.**
   
   Move to module top-level alongside the existing imports at lines 19–28.



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