Repository navigation
feat(mcp): add delete_dashboard and restore_dashboard tools - #40956
aminghadersohi wants to merge 5 commits into
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #40956 +/- ##
==========================================
- Coverage 64.60% 64.54% -0.07%
==========================================
Files 2712 2720 +8
Lines 151114 151572 +458
Branches 34751 34796 +45
==========================================
+ Hits 97625 97826 +201
- Misses 51663 51914 +251
- Partials 1826 1832 +6
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
97d20ac to
12dc548
Compare
There was a problem hiding this comment.
Code Review Agent Run #2b445d
Actionable Suggestions - 2
-
tests/unit_tests/mcp_service/dashboard/tool/test_delete_dashboard.py - 1
- Missing error case test coverage · Line 129-137
-
superset/mcp_service/dashboard/schemas.py - 1
- Missing schema validator tests · Line 616-667
Review Details
-
Files reviewed - 5 · Commit Range:
12dc548..12dc548- superset/mcp_service/app.py
- superset/mcp_service/dashboard/schemas.py
- superset/mcp_service/dashboard/tool/__init__.py
- superset/mcp_service/dashboard/tool/delete_dashboard.py
- tests/unit_tests/mcp_service/dashboard/tool/test_delete_dashboard.py
-
Files skipped - 0
-
Tools
- MyPy (Static Code Analysis) - ✔︎ Successful
- Astral Ruff (Static Code Analysis) - ✔︎ Successful
- Whispers (Secret Scanner) - ✔︎ Successful
- Detect-secrets (Secret Scanner) - ✔︎ Successful
Bito Usage Guide
Commands
Type the following command in the pull request comment and save the comment.
-
/review- Manually triggers a full AI review. -
/pause- Pauses automatic reviews on this pull request. -
/resume- Resumes automatic reviews. -
/resolve- Marks all Bito-posted review comments as resolved. -
/abort- Cancels all in-progress reviews.
Refer to the documentation for additional commands.
Configuration
This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at [email protected].
Documentation & Help
12dc548 to
acb7f3d
Compare
acb7f3d to
5df704d
Compare
There was a problem hiding this comment.
Code Review Agent Run #c968bf
Actionable Suggestions - 1
-
tests/unit_tests/mcp_service/dashboard/tool/test_delete_dashboard.py - 1
- Extract shared test fixtures to conftest · Line 30-30
Additional Suggestions - 1
-
tests/unit_tests/mcp_service/dashboard/tool/test_undelete_dashboard.py - 1
-
Incomplete command call verification · Line 169-192`test_slug_conflict` asserts the error response but does not verify `RestoreDashboardCommand.run()` was invoked. `test_successful_restore` (line 99) already calls `mock_restore_cmd.run.assert_called_once()`. Consistency requires the same check here — a silent command skip would not be caught by the current assertions.
-
Filtered by Review Rules
Bito filtered these suggestions based on rules created automatically for your feedback. Manage rules.
-
superset/mcp_service/dashboard/tool/delete_dashboard.py - 2
- Inline imports violate convention · Line 62-69
- Missing return type annotation · Line 52-53
Review Details
-
Files reviewed - 8 · Commit Range:
31a3b51..5df704d- superset/mcp_service/app.py
- superset/mcp_service/dashboard/schemas.py
- superset/mcp_service/dashboard/tool/__init__.py
- superset/mcp_service/dashboard/tool/delete_dashboard.py
- superset/mcp_service/dashboard/tool/undelete_dashboard.py
- tests/unit_tests/mcp_service/dashboard/test_dashboard_schemas.py
- tests/unit_tests/mcp_service/dashboard/tool/test_delete_dashboard.py
- tests/unit_tests/mcp_service/dashboard/tool/test_undelete_dashboard.py
-
Files skipped - 0
-
Tools
- MyPy (Static Code Analysis) - ✔︎ Successful
- Astral Ruff (Static Code Analysis) - ✔︎ Successful
- Whispers (Secret Scanner) - ✔︎ Successful
- Detect-secrets (Secret Scanner) - ✔︎ Successful
Bito Usage Guide
Commands
Type the following command in the pull request comment and save the comment.
-
/review- Manually triggers a full AI review. -
/pause- Pauses automatic reviews on this pull request. -
/resume- Resumes automatic reviews. -
/resolve- Marks all Bito-posted review comments as resolved. -
/abort- Cancels all in-progress reviews.
Refer to the documentation for additional commands.
Configuration
This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at [email protected].
Documentation & Help
- Add test for the DashboardDeleteFailedError path (associated alerts/reports) - Add sanitization tests for DeletedDashboardSummary, DeleteDashboardResponse, and UndeleteDashboardResponse schemas - Annotate test fixture return types
5df704d to
50985f8
Compare
Code Review Agent Run #43d5caActionable Suggestions - 0Additional Suggestions - 1
Filtered by Review RulesBito filtered these suggestions based on rules created automatically for your feedback. Manage rules.
Review Details
Bito Usage GuideCommands Type the following command in the pull request comment and save the comment.
Refer to the documentation for additional commands. Configuration This repository uses Documentation & Help |
Code Review Agent Run #e5b5d5Actionable Suggestions - 0Review Details
Bito Usage GuideCommands Type the following command in the pull request comment and save the comment.
Refer to the documentation for additional commands. Configuration This repository uses Documentation & Help |
Matches the platform vocabulary: the REST API exposes POST /api/v1/dashboard/<uuid>/restore, the command layer is RestoreDashboardCommand/BaseRestoreCommand, and SoftDeleteMixin's recovery method is restore(). "undelete" appeared nowhere else in the codebase.
✅ Deploy Preview for superset-docs-preview ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
| RestoreDashboardResponse, | ||
| ) | ||
|
|
||
| logger = logging.getLogger(__name__) |
There was a problem hiding this comment.
Suggestion: Add an explicit type annotation to the module logger variable to satisfy the type-hint requirement for relevant variables. [custom_rule]
Severity Level: Minor
Why it matters? 🤔
The module defines a long-lived logger variable without a type annotation even though its type is known and can be annotated. This matches the type-hint rule for relevant variables.
Rule source 📖
.cursor/rules/dev-standard.mdc (line 28)
(Use Cmd/Ctrl + Click for best experience)
Prompt for AI Agent 🤖
This is a comment left during a code review.
**Path:** superset/mcp_service/dashboard/tool/restore_dashboard.py
**Line:** 39:39
**Comment:**
*Custom Rule: Add an explicit type annotation to the module logger variable to satisfy the type-hint requirement for relevant variables.
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| dashboard = DashboardDAO.find_by_id( | ||
| request.dashboard_id, | ||
| skip_base_filter=True, | ||
| skip_visibility_filter=True, | ||
| ) |
There was a problem hiding this comment.
Suggestion: Annotate the dashboard lookup variable with its expected optional model type so this key local variable is explicitly typed. [custom_rule]
Severity Level: Minor
Why it matters? 🤔
The lookup result is assigned to a local variable without an explicit annotation, and the code later treats it as an optional dashboard object. That is a real omission under the type-hint rule.
Rule source 📖
.cursor/rules/dev-standard.mdc (line 28)
(Use Cmd/Ctrl + Click for best experience)
Prompt for AI Agent 🤖
This is a comment left during a code review.
**Path:** superset/mcp_service/dashboard/tool/restore_dashboard.py
**Line:** 75:79
**Comment:**
*Custom Rule: Annotate the dashboard lookup variable with its expected optional model type so this key local variable is explicitly typed.
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|
|
||
| with patch( | ||
| "superset.is_feature_enabled", | ||
| side_effect=lambda flag: flag == "SOFT_DELETE" and soft_delete_enabled, |
There was a problem hiding this comment.
Suggestion: Replace the untyped lambda with a named helper function that includes explicit parameter and return type hints. [custom_rule]
Severity Level: Minor
Why it matters? 🤔
The new lambda is an untyped Python function in modified code, and the project rule requires type hints on new or modified functions where possible. Replacing it with a named helper annotated with parameter and return types would satisfy the rule.
Rule source 📖
.cursor/rules/dev-standard.mdc (line 28)
(Use Cmd/Ctrl + Click for best experience)
Prompt for AI Agent 🤖
This is a comment left during a code review.
**Path:** tests/unit_tests/mcp_service/dashboard/tool/test_delete_dashboard.py
**Line:** 84:84
**Comment:**
*Custom Rule: Replace the untyped lambda with a named helper function that includes explicit parameter and return type hints.
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|
duplicate / dont need |
Code Review Agent Run #b80064Actionable Suggestions - 0Review Details
Bito Usage GuideCommands Type the following command in the pull request comment and save the comment.
Refer to the documentation for additional commands. Configuration This repository uses Documentation & Help |
SUMMARY
Adds
delete_dashboardandrestore_dashboardtools to the Superset MCP service. AI agents that generate test dashboards (e.g. viagenerate_dashboard) previously had no way to clean them up — this closes that CRUD gap, with a recovery path.delete_dashboarddashboard_id(int) and a requiredconfirmboolean safety gate. The tool refuses with a clear error unlessconfirm=trueis explicitly passed, forcing the caller (LLM) to state destructive intent. Single delete only — no bulk.DeleteDashboardCommand, so ownership checks, the report-schedule guard, and transactional semantics are identical to the REST API delete path. When theSOFT_DELETEfeature flag is enabled the command soft-deletes (recoverable); otherwise it hard-deletes.permanentfield, and echoes what was deleted (id, title, slug, uuid) so the agent can restore it later. Confirm-gate messaging also adapts to the flag.DashboardForbiddenError), and delete failure (including associated alerts/reports).restore_dashboardPOST /api/v1/dashboard/<uuid>/restore,RestoreDashboardCommand,SoftDeleteMixin.restore()).dashboard_id(int). Resolves the soft-deleted row (visibility filter skipped; base filter skipped so an owner's own trash stays reachable) and delegates toRestoreDashboardCommand, which re-checks ownership and slug uniqueness.DashboardSlugConflictError), and restore failure.destructiveHint=False).Both tools are tagged
mutatewithclass_permission_name="Dashboard"andmethod_permission_name="write". Title/slug and error text are sanitized before LLM exposure, matching the other dashboard tools.BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
N/A — backend MCP tools only, no UI changes.
TESTING INSTRUCTIONS
pytest tests/unit_tests/mcp_service/dashboard/tool/test_delete_dashboard.py tests/unit_tests/mcp_service/dashboard/tool/test_restore_dashboard.pySOFT_DELETEenabled: calldelete_dashboardwith{"dashboard_id": <id>, "confirm": false}and verify it refuses; retry with"confirm": trueand verify the response hasdeleted: true, permanent: false; then callrestore_dashboardwith the same ID and verify the dashboard is visible again.SOFT_DELETEdisabled:delete_dashboardreturnspermanent: trueandrestore_dashboardreports the dashboard as not found.ADDITIONAL INFORMATION
SOFT_DELETE(only for the recoverable-delete path andrestore_dashboard;delete_dashboardworks without it as a hard delete)