mikebridge commented on code in PR #42888:
URL: https://github.com/apache/superset/pull/42888#discussion_r3737115385
##########
superset/commands/deletion_retention/purge_cascade.py:
##########
@@ -196,23 +198,20 @@ def cascade_hard_delete(
window) requires only that it is still soft-deleted, so a restore
committed after the caller resolved the entity cannot be destroyed.
"""
- # pylint: disable=import-outside-toplevel
- from superset.connectors.sqla.models import SqlaTable
- from superset.models.slice import Slice
-
if enforce_window and cutoff is None:
raise ValueError("cutoff is required when enforce_window=True")
model = type(entity)
table = model.__table__
entity_id = entity.id
uuid = entity_uuid(entity)
- entity_type = _USER_FACING_TYPE.get(table.name, table.name)
+ policy: PurgeEntityPolicy = get_purge_policy(model)
+ entity_type: str = policy.entity_type
dangling_chart_uuids: list[str] = []
removed_dashboard_slices = 0
version_rows = 0
- permission_name = _dataset_permission_name(entity) if model is SqlaTable
else None
+ permission_name: str | None = policy.capture_permission_name(entity,
policy)
Review Comment:
Confirmed and fixed in 38272dfae1 — bito's endorsement was right, this was a
real race. `capture_permission_name` now runs inside `begin_nested()` after the
locked claim succeeds, and it reads `table_name`/`database_name` from the
database under that lock instead of trusting the in-memory entity, so an
identity change committed before the claim can no longer strand the renamed
permission. The callback signature also moved to `(session, policy,
entity_id)`, matching the other policy actions. Covered by the existing
dataset-permission integration tests (26/26).
_(Reply generated by Claude (AI) on behalf of @mikebridge.)_
--
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]