bito-code-review[bot] commented on code in PR #39303:
URL: https://github.com/apache/superset/pull/39303#discussion_r3294550403
##########
superset/commands/report/base.py:
##########
@@ -50,6 +53,34 @@ def run(self) -> Any:
def validate(self) -> None:
pass
+ def _check_chart_access(
+ self, chart_id: int, exceptions: list[ValidationError]
+ ) -> None:
+ """Validate chart exists and the current user can access it."""
+ chart = ChartDAO.find_by_id(chart_id)
+ if not chart:
+ exceptions.append(ChartNotFoundValidationError())
+ else:
+ try:
+ security_manager.raise_for_access(viz=chart)
+ except SupersetSecurityException as ex:
+ raise ReportScheduleForbiddenError() from ex
+ self._properties["chart"] = chart
+
+ def _check_dashboard_access(
+ self, dashboard_id: int, exceptions: list[ValidationError]
+ ) -> None:
+ """Validate dashboard exists and the current user can access it."""
+ dashboard = DashboardDAO.find_by_id(dashboard_id)
+ if not dashboard:
+ exceptions.append(DashboardNotFoundValidationError())
+ else:
+ try:
+ security_manager.raise_for_access(dashboard=dashboard)
+ except SupersetSecurityException as ex:
+ raise ReportScheduleForbiddenError() from ex
+ self._properties["dashboard"] = dashboard
Review Comment:
<!-- Bito Reply -->
The suggestion in the PR comment highlights a potential issue with the newly
added `_check_chart_access` and `_check_dashboard_access` methods in the
`base.py` file. These methods contain nearly identical logic, differing only in
the DAO used, exception types raised, and the property key set. The suggestion
recommends consolidating this logic into a shared helper method to reduce
duplication and improve maintainability.
--
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]