bito-code-review[bot] commented on code in PR #40129:
URL: https://github.com/apache/superset/pull/40129#discussion_r3338050658
##########
superset/charts/api.py:
##########
@@ -122,6 +129,7 @@ def ensure_thumbnails_enabled(self) -> Optional[Response]:
RouteMethod.IMPORT,
RouteMethod.RELATED,
"bulk_delete", # not using RouteMethod since locally defined
+ "restore",
Review Comment:
<div>
<div id="suggestion">
<div id="issue"><b>Missing RBAC permission for restore</b></div>
<div id="fix">
The `restore` route is exposed via `include_route_methods` at line 132 but
`method_permission_name` at line 143 only inherits
`MODEL_API_RW_METHOD_PERMISSION_MAP`, which does not define `"restore"`. FAB's
`@protect()` decorator uses `method_permission_name` to gate access — a method
not listed defaults to an unpredictable fallback. Adding `"restore": "write"`
aligns with the pattern in `themes/api.py:83-89` for custom methods and ensures
the endpoint requires the same write permission as `bulk_delete`.
</div>
<details>
<summary>
<b>Code suggestion</b>
</summary>
<blockquote>Check the AI-generated fix before applying</blockquote>
<div id="code">
```
--- a/superset/charts/api.py
+++ b/superset/charts/api.py
@@ -140,7 +140,10 @@ class ChartRestApi(SoftDeleteApiMixin,
BaseSupersetModelRestApi):
"warm_up_cache",
}
class_permission_name = "Chart"
- method_permission_name = MODEL_API_RW_METHOD_PERMISSION_MAP
+ method_permission_name = {
+ **MODEL_API_RW_METHOD_PERMISSION_MAP,
+ "restore": "write",
+ }
```
</div>
</details>
</div>
<small><i>Code Review Run #2eef54</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]