Repository navigation
feat(mcp): deleted_state trash listing for list_charts and list_dashboards - #41855
Conversation
…oards Expose the soft-delete trash (apache#40128, apache#40129) to MCP list tools via a deleted_state param ('include'/'only'). Reuses the REST Chart/DashboardDeletedStateFilter classes — which own the restore- audience scoping (owners or admins only) — through BaseDAO.list's custom_filters hook, with a DeletedStateBoundFilter adapter binding the caller's value since the DAO invokes custom filters with value=None. The DAO call is wrapped in the skip_visibility_filter context manager so the soft-delete ORM listener is bypassed for both the count and fetch executions, with guaranteed release. deleted_at is forced into loaded columns and added to ChartInfo/DashboardInfo so trashed rows are distinguishable in 'include' mode. 10 unit tests. Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_014z1fQxTadTEvpCJLx9WnB8
Code Review Agent Run #811aeaActionable Suggestions - 0Filtered 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 |
|
The suggestion to add an explicit return type hint to the fixture function is correct and aligns with standard Python type-annotation practices. To resolve this, you should update the function signature to include the appropriate return type, for example: Regarding other comments on this PR, I have checked the available review data, and there are no additional comments recorded in the provided review file. Therefore, no further fixes are required at this time. tests/unit_tests/mcp_service/dashboard/tool/test_list_dashboards_deleted_state.py |
✅ Deploy Preview for superset-docs-preview ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #41855 +/- ##
==========================================
- Coverage 64.88% 64.82% -0.06%
==========================================
Files 2742 2746 +4
Lines 153378 153671 +293
Branches 35168 35201 +33
==========================================
+ Hits 99516 99616 +100
- Misses 51958 52145 +187
- Partials 1904 1910 +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:
|
…ip rename: owned_by_me -> edited_by_me, editor_filter_column)
Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_014z1fQxTadTEvpCJLx9WnB8
Code Review Agent Run #81f0c8Actionable 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 |
aminghadersohi
left a comment
There was a problem hiding this comment.
RBAC/tenancy verdict: SOUND. BaseDAO.list() applies base_filter (ChartFilter/DashboardAccessFilter) unconditionally, before custom_filters — the new DeletedStateBoundFilter adapter only forwards the caller's choice into the pre-existing ChartDeletedStateFilter/DashboardDeletedStateFilter (OSS #40130, untouched by this diff), which already restrict soft-deleted rows to editors/admins. Trashed-row visibility = base_filter ∩ editor-or-admin — never looser than live-row visibility. Guest/embedded tokens excluded by the same pre-existing guest-scoping check. No cross-tenant/guest trash exposure found.
Default-is-active: confirmed — deleted_state defaults to None, and _build_deleted_state_filter short-circuits before any filter/bypass engages, so existing callers are unaffected.
deleted_state validation: sound — bounded Literal["include","only"] | None at the schema layer, with a defensive re-validation in the shared core class.
Two findings below (no BLOCKER/HIGH). Existing codeant/bito type-annotation threads are already declined by the author with a standing rationale — not re-filed here.
- Direct unit tests for the defensive core branches: None short-circuit, invalid-value rejection (which pydantic's Literal shields at the schema layer), and unconfigured-resource rejection - Mirror the three chart-side tests on the dashboard tool for parity (review: aminghadersohi) Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_014z1fQxTadTEvpCJLx9WnB8
Code Review Agent Run #dcec7fActionable 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 |
aminghadersohi
left a comment
There was a problem hiding this comment.
Re-review at new HEAD 3b1d364dfa5dda5771c207fd0d551b6084e7328d (prior HEAD 2420e52946160ce64df2489e65c03bf079a4cc18, review #4688865568). Diff is test-only — no production code changed since round 1, so the round-1 RBAC-scoping / default-is-active / deleted_state-validation verdicts still hold as-is.
Both round-1 findings are cleanly closed by commit 3b1d364dfa:
- MEDIUM (
mcp_core.py:334coverage gap):test_mcp_core.pynow hastest_build_deleted_state_filter_none_short_circuits,test_build_deleted_state_filter_rejects_invalid_value, andtest_build_deleted_state_filter_rejects_unconfigured_resource— exercising_build_deleted_state_filterdirectly (bypassing the pydanticLiteralschema gate), which is exactly the coverage gap flagged: bothraise ValueErrorbranches are now hit by a real test, not just shielded by schema validation. - NIT (dashboard test parity):
test_list_dashboards_deleted_state.pynow mirrors all three chart-side tests (..._default_has_no_deleted_state_filter,..._no_deleted_state_no_visibility_bypass,..._deleted_state_invalid_value_rejected).
No new findings from us this round. The 3 new codeant threads since round 1 are the same inferable-type-annotation nit pattern already declined by the author with a standing rationale (constants/locals/test lambdas with inferable types, mypy passes) — not re-raised here.
|
@gkneighb did you want to address anything from the thread before merging? Seems we're not blocked, per se, but I don't want to cause the need for a follow-up PR. |
|
Nothing outstanding — all review threads are resolved and CI is green. The two findings from the review pass (defensive-branch coverage in |
…oards (apache#41855) Co-authored-by: Greg Neighbors <[email protected]> Co-authored-by: Claude Fable 5 <[email protected]>
…e for list_datasets The MCP server can create datasets but cannot delete them, so an agent that creates exploratory virtual datasets has no way to clean them up. Charts and dashboards already have delete, restore and trash listing (apache#41472, apache#41842, apache#41855), and dataset soft-delete landed in apache#40130, but the MCP side of it was never added. - delete_dataset: delete by numeric ID or UUID via DeleteDatasetCommand, which enforces editorship. The response reports whether the row went to trash (SOFT_DELETE) or was removed permanently, plus the number of charts and dashboards built on the dataset, counted the same way as GET /api/v1/dataset/<pk>/related_objects so inaccessible objects are not disclosed. - restore_dataset: restore a trashed dataset via RestoreDatasetCommand, with distinct NotFound, NotDeleted and LogicalDuplicate errors. The lookup uses the same filter bypasses as the command. - list_datasets: deleted_state ('include' / 'only') reusing DatasetDeletedStateFilter, so trashed datasets can be found and restored. DatasetInfo gains deleted_at. Co-Authored-By: Claude Opus 5 <[email protected]>
…dashboards #41855 added a deleted_state parameter to list_charts and list_dashboards for listing soft-deleted (trashed) objects, but the MCP server docs never mentioned it. Co-Authored-By: Evan Rusackas <[email protected]> Co-Authored-By: Claude Sonnet 5 <[email protected]>
SUMMARY
Adds a
deleted_stateparameter ("include"/"only") to thelist_chartsandlist_dashboardsMCP tools, mirroring the RESTchart_deleted_state/dashboard_deleted_staterison filters introduced with soft-delete (#40128 / #40129). Without it, an MCP client has no way to enumerate trashed objects — which makes trash effectively invisible to LLM agents (and unrestorable, once restore tools land: #41842).Design notes:
ChartDeletedStateFilter/DashboardDeletedStateFilterown the restore-audience scoping (only owners — or admins — may enumerate soft-deleted rows).ModelListCorepasses them throughBaseDAO.list's existingcustom_filtershook via a smallDeletedStateBoundFilteradapter, because the DAO invokes custom filters asapply(query, None)and the FAB filter treatsNoneas "live rows only" — the adapter binds the caller's actual value. Keeping the audience scoping in one class means the cross-entity deleted-state contract can't drift between REST and MCP.skip_visibility_filtercontext manager. The soft-delete ORM listener appendsdeleted_at IS NULLat execution time, andBaseDAO.listexecutes twice (count + fetch), so a per-query bypass is not enough. The context manager guarantees release even on exceptions, so code running later in the same request sees normal filtered visibility — the same scope-discipline the REST layer implements viaSoftDeleteApiMixin.deleted_atis forced into loaded columns wheneverdeleted_stateis used (and added to theChartInfo/DashboardInfoschemas + serializers), so trashed rows are distinguishable from live ones inincludemode.ModelListCoredoesn't configure a deleted-state filter reject the parameter with a clear error.Part of a series filling out MCP resource-lifecycle coverage (delete: #41472, restore: #41842).
BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
N/A (MCP service tools; no UI changes)
TESTING INSTRUCTIONS
Unit tests (10 new):
pytest tests/unit_tests/mcp_service/chart/tool/test_list_charts_deleted_state.py \ tests/unit_tests/mcp_service/dashboard/tool/test_list_dashboards_deleted_state.py \ tests/unit_tests/mcp_service/test_mcp_core.pyThe underlying filter semantics (audience scoping, include/only behavior) are covered by the existing REST integration suite (
tests/integration_tests/charts/soft_delete_tests.py), and theskip_visibility_filtercontext manager bytests/unit_tests/models/test_soft_delete_mixin.py— this PR reuses both mechanisms rather than duplicating them.Manual: with
FEATURE_FLAGS = {"SOFT_DELETE": True}, delete a chart you own, then calllist_chartswith{"deleted_state": "only"}— the trashed chart is returned with a non-nulldeleted_at. As a non-admin, another user's trashed charts do not appear.ADDITIONAL INFORMATION
SOFT_DELETE(to produce trashed rows; the parameter itself is not gated)🤖 Generated with Claude Code
https://claude.ai/code/session_014z1fQxTadTEvpCJLx9WnB8