codeant-ai-for-open-source[bot] commented on code in PR #42888:
URL: https://github.com/apache/superset/pull/42888#discussion_r3736767934
##########
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:
**Suggestion:** The permission identity is captured before the row is
claimed and locked. If `table_name` or `database_id` changes and commits
between this snapshot and the claim, the cascade can delete the current row but
remove the permission for its previous identity, leaving the actual permission
artifact behind. Capture the permission name after the locked claim using the
current database row state, or include the identity in the locked snapshot.
[race condition]
<details>
<summary><b>Severity Level:</b> Major ⚠️</summary>
```mdx
- ❌ Dataset permission artifacts can remain orphaned.
- ⚠️ Dataset access metadata may require manual cleanup.
- ⚠️ Affects scheduled and operator force purges.
```
</details>
[](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=0ec4ff6c7c074900934afa1c9ed36418&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
[](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=0ec4ff6c7c074900934afa1c9ed36418&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
*(Use Cmd/Ctrl + Click for best experience)*
<details>
<summary><b>Prompt for AI Agent 🤖 </b></summary>
```mdx
This is a comment left during a code review.
**Path:** superset/commands/deletion_retention/purge_cascade.py
**Line:** 214:214
**Comment:**
*Race Condition: The permission identity is captured before the row is
claimed and locked. If `table_name` or `database_id` changes and commits
between this snapshot and the claim, the cascade can delete the current row but
remove the permission for its previous identity, leaving the actual permission
artifact behind. Capture the permission name after the locked claim using the
current database row state, or include the identity in the locked snapshot.
Validate the correctness of the flagged issue. If correct, How can I resolve
this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask
user if the user wants to fix the rest of the comments as well. if said yes,
then fetch all the comments validate the correctness and implement a minimal fix
```
</details>
<a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F42888&comment_hash=f48d1c74196972fcd955647fe6b676a7f2f80f07f53fe81fd8f7e281f6afe124&reaction=like'>👍</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F42888&comment_hash=f48d1c74196972fcd955647fe6b676a7f2f80f07f53fe81fd8f7e281f6afe124&reaction=dislike'>👎</a>
--
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]