bito-code-review[bot] commented on code in PR #40329:
URL: https://github.com/apache/superset/pull/40329#discussion_r3327906181
##########
superset/commands/tag/delete.py:
##########
@@ -85,6 +95,30 @@ def validate(self) -> None:
if exceptions:
raise TagInvalidError(exceptions=exceptions)
+ def _validate_object_access(
+ self, object_type: ObjectType, object_id: int, exceptions: list[Any]
+ ) -> None:
+ """Validate that the current user has access to the target object."""
+ if object_type not in OBJECT_TYPE_MODEL_MAP:
+ exceptions.append(
+ TaggedObjectDeleteFailedError(
+ f"Access denied for {object_type} {object_id}"
+ )
+ )
+ return
Review Comment:
<div>
<div id="suggestion">
<div id="issue"><b>Dead Code: Unreachable Check</b></div>
<div id="fix">
The check at line 102 is unreachable dead code. `validate()` calls
`to_object_type()` which returns `None` for invalid types and raises
`TaggedObjectDeleteFailedError` before `_validate_object_access` is invoked. At
line 99, `object_type: ObjectType` is already guaranteed to be a valid enum
member — `ObjectType` has exactly 4 values (query, chart, dashboard, dataset)
and `OBJECT_TYPE_MODEL_MAP` covers all 4.
</div>
</div>
<small><i>Code Review Run #bcb4a2</i></small>
</div>
---
Should Bito avoid suggestions like this for future reviews? (<a
href=https://alpha.bito.ai/home/ai-agents/review-rules>Manage Rules</a>)
- [ ] Yes, avoid them
--
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]