You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by "gkneighb (via GitHub)" <gi...@apache.org> on 2026/07/07 15:53:16 UTC

[PR] feat(mcp): deleted_state trash listing for list_charts and list_dashboards [superset]

gkneighb opened a new pull request, #41855:
URL: https://github.com/apache/superset/pull/41855

   ### SUMMARY
   
   Adds a `deleted_state` parameter (`"include"` / `"only"`) to the `list_charts` and `list_dashboards` MCP tools, mirroring the REST `chart_deleted_state` / `dashboard_deleted_state` rison 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:
   
   - **The REST filter classes are reused, not reimplemented.** `ChartDeletedStateFilter` / `DashboardDeletedStateFilter` own the restore-audience scoping (only owners — or admins — may enumerate soft-deleted rows). `ModelListCore` passes them through `BaseDAO.list`'s existing `custom_filters` hook via a small `DeletedStateBoundFilter` adapter, because the DAO invokes custom filters as `apply(query, None)` and the FAB filter treats `None` as "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.
   - **Session-scoped visibility bypass via the `skip_visibility_filter` context manager.** The soft-delete ORM listener appends `deleted_at IS NULL` at execution time, and `BaseDAO.list` executes 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 via `SoftDeleteApiMixin`.
   - **`deleted_at` is forced into loaded columns** whenever `deleted_state` is used (and added to the `ChartInfo`/`DashboardInfo` schemas + serializers), so trashed rows are distinguishable from live ones in `include` mode.
   - Resources whose `ModelListCore` doesn'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):
   
   ```bash
   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.py
   ```
   
   The 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 the `skip_visibility_filter` context manager by `tests/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 call `list_charts` with `{"deleted_state": "only"}` — the trashed chart is returned with a non-null `deleted_at`. As a non-admin, another user's trashed charts do not appear.
   
   ### ADDITIONAL INFORMATION
   
   - [ ] Has associated issue:
   - [x] Required feature flags: `SOFT_DELETE` (to produce trashed rows; the parameter itself is not gated)
   - [ ] Changes UI
   - [ ] Includes DB Migration (follow approval process in [SIP-59](https://github.com/apache/superset/issues/13351))
     - [ ] Migration is atomic, supports rollback & is backwards-compatible
     - [ ] Confirm DB migration upgrade and downgrade tested
     - [ ] Runtime estimates and downtime expectations provided
   - [x] Introduces new feature or API
   - [ ] Removes existing feature or API
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   
   https://claude.ai/code/session_014z1fQxTadTEvpCJLx9WnB8
   


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] feat(mcp): deleted_state trash listing for list_charts and list_dashboards [superset]

Posted by "gkneighb (via GitHub)" <gi...@apache.org>.
gkneighb commented on code in PR #41855:
URL: https://github.com/apache/superset/pull/41855#discussion_r3575440756


##########
superset/mcp_service/mcp_core.py:
##########
@@ -284,8 +315,31 @@ def _call_dao_list(
             search=search,
             search_columns=self.search_columns,
             columns=columns_to_load,
+            custom_filters=custom_filters,
         )
 
+    def _build_deleted_state_filter(
+        self, deleted_state: str | None
+    ) -> DeletedStateBoundFilter | None:
+        """Validate deleted_state and bind it to the entity's FAB filter.
+
+        Returns None when trash listing was not requested. Raises for a
+        value other than ``include``/``only`` or when the resource has no
+        deleted-state filter configured.
+        """
+        if deleted_state is None:
+            return None
+        normalized = str(deleted_state).lower().strip()
+        if normalized not in {"include", "only"}:
+            raise ValueError("deleted_state must be 'include' or 'only'")

Review Comment:
   Added in 3b1d364dfa — three direct unit tests on _build_deleted_state_filter: the None short-circuit, the defensive invalid-value rejection (which pydantic's Literal shields at the schema layer, as you noted), and the unconfigured-resource rejection.



##########
tests/unit_tests/mcp_service/dashboard/tool/test_list_dashboards_deleted_state.py:
##########
@@ -0,0 +1,132 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+"""Unit tests for list_dashboards ``deleted_state`` trash listing.
+
+Mirrors the list_charts deleted_state tests: DAO custom filter pass-through,
+session-scoped visibility bypass around the DAO call, and ``deleted_at``
+forced into loaded columns and the serialized response.
+"""
+
+from collections.abc import Iterator
+from datetime import datetime
+from unittest.mock import MagicMock, Mock, patch
+from uuid import UUID
+
+import pytest
+from fastmcp import Client
+
+from superset.mcp_service.app import mcp
+from superset.utils import json
+
+_DAO_LIST = "superset.daos.dashboard.DashboardDAO.list"
+_BYPASS = "superset.mcp_service.mcp_core.skip_visibility_filter"
+
+
+@pytest.fixture
+def mcp_server() -> object:
+    return mcp
+
+
+@pytest.fixture(autouse=True)
+def mock_auth() -> Iterator[Mock]:
+    with patch("superset.mcp_service.auth.get_user_from_request") as mock_get_user:
+        mock_user = Mock()
+        mock_user.id = 1
+        mock_user.username = "admin"
+        mock_get_user.return_value = mock_user
+        yield mock_get_user
+
+
+def _trashed_dashboard_row() -> Mock:
+    row = Mock(
+        spec=[
+            "id",
+            "dashboard_title",
+            "slug",
+            "published",
+            "changed_on",
+            "created_on",
+            "uuid",
+            "deleted_at",
+        ]
+    )
+    row.id = 1
+    row.dashboard_title = "Trashed Dashboard"
+    row.slug = None
+    row.published = False
+    row.changed_on = datetime(2026, 6, 1)
+    row.created_on = datetime(2026, 5, 1)
+    row.uuid = UUID("aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee")
+    row.deleted_at = datetime(2026, 7, 1)
+    return row
+
+
+@patch(_DAO_LIST)
+@pytest.mark.asyncio
+async def test_list_dashboards_deleted_state_only_passes_custom_filter(
+    mock_list: Mock, mcp_server: object
+) -> None:
+    mock_list.return_value = ([], 0)
+
+    async with Client(mcp_server) as client:
+        await client.call_tool(
+            "list_dashboards", {"request": {"deleted_state": "only"}}
+        )
+
+    kwargs = mock_list.call_args.kwargs
+    assert "deleted_state" in (kwargs.get("custom_filters") or {})
+    assert "deleted_at" in kwargs["columns"]
+
+
+@patch(_BYPASS)
+@patch(_DAO_LIST)
+@pytest.mark.asyncio
+async def test_list_dashboards_deleted_state_wraps_visibility_bypass(
+    mock_list: Mock, mock_bypass: MagicMock, mcp_server: object
+) -> None:
+    from superset.models.dashboard import Dashboard
+
+    mock_list.return_value = ([], 0)
+    mock_bypass.return_value.__enter__ = Mock(return_value=None)
+    mock_bypass.return_value.__exit__ = Mock(return_value=False)
+
+    async with Client(mcp_server) as client:
+        await client.call_tool(
+            "list_dashboards", {"request": {"deleted_state": "include"}}
+        )
+
+    mock_bypass.assert_called_once()
+    assert Dashboard in mock_bypass.call_args.args
+
+
+@patch(_DAO_LIST)
+@pytest.mark.asyncio
+async def test_list_dashboards_deleted_state_serializes_deleted_at(
+    mock_list: Mock, mcp_server: object
+) -> None:
+    mock_list.return_value = ([_trashed_dashboard_row()], 1)
+
+    async with Client(mcp_server) as client:
+        result = await client.call_tool(
+            "list_dashboards", {"request": {"deleted_state": "only"}}
+        )
+
+    data = json.loads(result.content[0].text)
+    assert data["dashboards"][0]["id"] == 1
+    assert data["dashboards"][0]["deleted_at"] is not None
+    assert "deleted_at" in data["columns_loaded"]

Review Comment:
   Added in 3b1d364dfa — all three chart-side tests mirrored on the dashboard tool.



-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] feat(mcp): deleted_state trash listing for list_charts and list_dashboards [superset]

Posted by "codeant-ai-for-open-source[bot] (via GitHub)" <gi...@apache.org>.
codeant-ai-for-open-source[bot] commented on code in PR #41855:
URL: https://github.com/apache/superset/pull/41855#discussion_r3575421682


##########
tests/unit_tests/mcp_service/dashboard/tool/test_list_dashboards_deleted_state.py:
##########
@@ -0,0 +1,176 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+"""Unit tests for list_dashboards ``deleted_state`` trash listing.
+
+Mirrors the list_charts deleted_state tests: DAO custom filter pass-through,
+session-scoped visibility bypass around the DAO call, and ``deleted_at``
+forced into loaded columns and the serialized response.
+"""
+
+from collections.abc import Iterator
+from datetime import datetime
+from unittest.mock import MagicMock, Mock, patch
+from uuid import UUID
+
+import pytest
+from fastmcp import Client
+
+from superset.mcp_service.app import mcp
+from superset.utils import json
+
+_DAO_LIST = "superset.daos.dashboard.DashboardDAO.list"
+_BYPASS = "superset.mcp_service.mcp_core.skip_visibility_filter"
+
+
+@pytest.fixture
+def mcp_server() -> object:
+    return mcp
+
+
+@pytest.fixture(autouse=True)
+def mock_auth() -> Iterator[Mock]:
+    with patch("superset.mcp_service.auth.get_user_from_request") as mock_get_user:
+        mock_user = Mock()
+        mock_user.id = 1
+        mock_user.username = "admin"
+        mock_get_user.return_value = mock_user
+        yield mock_get_user
+
+
+def _trashed_dashboard_row() -> Mock:
+    row = Mock(
+        spec=[
+            "id",
+            "dashboard_title",
+            "slug",
+            "published",
+            "changed_on",
+            "created_on",
+            "uuid",
+            "deleted_at",
+        ]
+    )
+    row.id = 1
+    row.dashboard_title = "Trashed Dashboard"
+    row.slug = None
+    row.published = False
+    row.changed_on = datetime(2026, 6, 1)
+    row.created_on = datetime(2026, 5, 1)
+    row.uuid = UUID("aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee")
+    row.deleted_at = datetime(2026, 7, 1)
+    return row
+
+
+@patch(_DAO_LIST)
+@pytest.mark.asyncio
+async def test_list_dashboards_deleted_state_only_passes_custom_filter(
+    mock_list: Mock, mcp_server: object
+) -> None:
+    mock_list.return_value = ([], 0)
+
+    async with Client(mcp_server) as client:
+        await client.call_tool(
+            "list_dashboards", {"request": {"deleted_state": "only"}}
+        )
+
+    kwargs = mock_list.call_args.kwargs

Review Comment:
   **Suggestion:** Add a concrete type annotation for this local variable (for example a typed mapping) when extracting call kwargs. [custom_rule]
   
   **Severity Level:** Minor 🧹
   <details>
   <summary><b>Why it matters? ⭐ </b></summary>
   
   This is a newly introduced local variable holding call keyword arguments and can be annotated. Because the file adds new Python code and omits a type hint on an annotatable variable, it matches the type-hint rule.
   </details>
   <details>
   <summary><b>Rule source 📖 </b></summary>
   
   .cursor/rules/dev-standard.mdc (line 28)
   </details>
   
   [![Fix in Cursor](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-cursor-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=07b7c475b1754536ba6d875dbaa23207&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset) [![Fix in VSCode Claude](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-vscode-claude-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=07b7c475b1754536ba6d875dbaa23207&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
   
   *(Use Cmd/Ctrl + Click for best experience)*
   <details>
   <summary><b>Prompt for AI Agent 🤖 </b></summary>
   
   ```mdx
   This is a comment left during a code review.
   
   **Path:** tests/unit_tests/mcp_service/dashboard/tool/test_list_dashboards_deleted_state.py
   **Line:** 91:91
   **Comment:**
   	*Custom Rule: Add a concrete type annotation for this local variable (for example a typed mapping) when extracting call kwargs.
   
   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
   ```
   </details>
   <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41855&comment_hash=8e2e8a262a3744c374b44271096b13608e8e018254a4414d743aa6a9b9f09a3b&reaction=like'>👍</a> | <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41855&comment_hash=8e2e8a262a3744c374b44271096b13608e8e018254a4414d743aa6a9b9f09a3b&reaction=dislike'>👎</a>



-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] feat(mcp): deleted_state trash listing for list_charts and list_dashboards [superset]

Posted by "codeant-ai-for-open-source[bot] (via GitHub)" <gi...@apache.org>.
codeant-ai-for-open-source[bot] commented on code in PR #41855:
URL: https://github.com/apache/superset/pull/41855#discussion_r3575564326


##########
tests/unit_tests/mcp_service/test_mcp_core.py:
##########
@@ -312,3 +316,70 @@ def test_explicit_title_column_overrides_dao_attribute() -> None:
 )
 def test_slugify_handles_edge_cases(identifier: str, expected_slug: str) -> None:
     assert _slugify(identifier) == expected_slug
+
+
+def test_deleted_state_bound_filter_delegates_bound_value() -> None:
+    """The adapter passed to DAO custom_filters must forward the bound
+    deleted_state value — BaseDAO.list invokes custom filters with
+    ``apply(query, None)``, which the FAB filter would treat as 'live only'."""
+    from unittest.mock import Mock
+
+    from superset.mcp_service.mcp_core import DeletedStateBoundFilter
+
+    inner = Mock()
+    inner.apply.return_value = "filtered-query"
+    bound = DeletedStateBoundFilter(inner, "only", model=Mock)
+
+    assert bound.apply("query", None) == "filtered-query"
+    inner.apply.assert_called_once_with("query", "only")
+
+
+def _build_list_core(
+    deleted_state_filter: type | None = None,
+) -> "ModelListCore[Any]":
+    """Minimal ModelListCore for exercising _build_deleted_state_filter."""
+    from unittest.mock import MagicMock
+
+    from pydantic import BaseModel
+
+    class _Out(BaseModel):
+        pass
+
+    return ModelListCore(
+        dao_class=MagicMock(),
+        output_schema=_Out,
+        item_serializer=lambda obj, cols: None,

Review Comment:
   ✅ **Customized review instruction saved!**
   
   **Instruction:**
   > Do not flag untyped lambdas, locals, or constants when their types are inferable and the code already passes mypy; this is acceptable across the Python codebase.
   
   **Applied to:**
     - `**/*.py`
   
   ---
   💡 *To manage or update this instruction, visit: [CodeAnt AI Settings](https://app.codeant.ai/org/settings/learnings)*



##########
tests/unit_tests/mcp_service/chart/tool/test_list_charts_deleted_state.py:
##########
@@ -0,0 +1,171 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+"""Unit tests for list_charts ``deleted_state`` trash listing.
+
+The deleted_state param opts the list query into surfacing soft-deleted
+charts: the session-scoped visibility bypass wraps the DAO call, the REST
+``ChartDeletedStateFilter`` (which owns the restore-audience scoping) is
+passed through as a DAO custom filter, and ``deleted_at`` is forced into the
+loaded columns so trashed rows are distinguishable in the response.
+"""
+
+from collections.abc import Iterator
+from datetime import datetime
+from unittest.mock import MagicMock, Mock, patch
+from uuid import UUID
+
+import pytest
+from fastmcp import Client
+from fastmcp.exceptions import ToolError
+
+from superset.mcp_service.app import mcp
+from superset.utils import json
+
+_DAO_LIST = "superset.daos.chart.ChartDAO.list"

Review Comment:
   ✅ **Customized review instruction saved!**
   
   **Instruction:**
   > Do not flag inferable-type constants, locals, or test lambdas in Python code; the codebase intentionally leaves these unannotated and mypy passes.
   
   **Applied to:**
     - `**/*.py`
   
   ---
   💡 *To manage or update this instruction, visit: [CodeAnt AI Settings](https://app.codeant.ai/org/settings/learnings)*



##########
tests/unit_tests/mcp_service/dashboard/tool/test_list_dashboards_deleted_state.py:
##########
@@ -0,0 +1,176 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+"""Unit tests for list_dashboards ``deleted_state`` trash listing.
+
+Mirrors the list_charts deleted_state tests: DAO custom filter pass-through,
+session-scoped visibility bypass around the DAO call, and ``deleted_at``
+forced into loaded columns and the serialized response.
+"""
+
+from collections.abc import Iterator
+from datetime import datetime
+from unittest.mock import MagicMock, Mock, patch
+from uuid import UUID
+
+import pytest
+from fastmcp import Client
+
+from superset.mcp_service.app import mcp
+from superset.utils import json
+
+_DAO_LIST = "superset.daos.dashboard.DashboardDAO.list"
+_BYPASS = "superset.mcp_service.mcp_core.skip_visibility_filter"
+
+
+@pytest.fixture
+def mcp_server() -> object:
+    return mcp
+
+
+@pytest.fixture(autouse=True)
+def mock_auth() -> Iterator[Mock]:
+    with patch("superset.mcp_service.auth.get_user_from_request") as mock_get_user:
+        mock_user = Mock()
+        mock_user.id = 1
+        mock_user.username = "admin"
+        mock_get_user.return_value = mock_user
+        yield mock_get_user
+
+
+def _trashed_dashboard_row() -> Mock:
+    row = Mock(
+        spec=[
+            "id",
+            "dashboard_title",
+            "slug",
+            "published",
+            "changed_on",
+            "created_on",
+            "uuid",
+            "deleted_at",
+        ]
+    )
+    row.id = 1
+    row.dashboard_title = "Trashed Dashboard"
+    row.slug = None
+    row.published = False
+    row.changed_on = datetime(2026, 6, 1)
+    row.created_on = datetime(2026, 5, 1)
+    row.uuid = UUID("aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee")
+    row.deleted_at = datetime(2026, 7, 1)
+    return row
+
+
+@patch(_DAO_LIST)
+@pytest.mark.asyncio
+async def test_list_dashboards_deleted_state_only_passes_custom_filter(
+    mock_list: Mock, mcp_server: object
+) -> None:
+    mock_list.return_value = ([], 0)
+
+    async with Client(mcp_server) as client:
+        await client.call_tool(
+            "list_dashboards", {"request": {"deleted_state": "only"}}
+        )
+
+    kwargs = mock_list.call_args.kwargs

Review Comment:
   ✅ **Customized review instruction saved!**
   
   **Instruction:**
   > Do not flag missing type annotations on inferable locals, constants, or test lambdas in Python files; only suggest annotations when the type is not obvious or materially improves clarity.
   
   **Applied to:**
     - `**/*.py`
   
   ---
   💡 *To manage or update this instruction, visit: [CodeAnt AI Settings](https://app.codeant.ai/org/settings/learnings)*



-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] feat(mcp): deleted_state trash listing for list_charts and list_dashboards [superset]

Posted by "gkneighb (via GitHub)" <gi...@apache.org>.
gkneighb commented on code in PR #41855:
URL: https://github.com/apache/superset/pull/41855#discussion_r3565560255


##########
tests/unit_tests/mcp_service/dashboard/tool/test_list_dashboards_deleted_state.py:
##########
@@ -0,0 +1,132 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+"""Unit tests for list_dashboards ``deleted_state`` trash listing.
+
+Mirrors the list_charts deleted_state tests: DAO custom filter pass-through,
+session-scoped visibility bypass around the DAO call, and ``deleted_at``
+forced into loaded columns and the serialized response.
+"""
+
+from collections.abc import Iterator
+from datetime import datetime
+from unittest.mock import MagicMock, Mock, patch
+from uuid import UUID
+
+import pytest
+from fastmcp import Client
+
+from superset.mcp_service.app import mcp
+from superset.utils import json
+
+_DAO_LIST = "superset.daos.dashboard.DashboardDAO.list"

Review Comment:
   Declining, standing rationale: constants and locals with inferable types are unannotated across this codebase (the same patterns appear in all seven in-tree chart plugins and throughout mcp_service); mypy passes. Identical future findings will be declined the same way.



##########
tests/unit_tests/mcp_service/dashboard/tool/test_list_dashboards_deleted_state.py:
##########
@@ -0,0 +1,132 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+"""Unit tests for list_dashboards ``deleted_state`` trash listing.
+
+Mirrors the list_charts deleted_state tests: DAO custom filter pass-through,
+session-scoped visibility bypass around the DAO call, and ``deleted_at``
+forced into loaded columns and the serialized response.
+"""
+
+from collections.abc import Iterator
+from datetime import datetime
+from unittest.mock import MagicMock, Mock, patch
+from uuid import UUID
+
+import pytest
+from fastmcp import Client
+
+from superset.mcp_service.app import mcp
+from superset.utils import json
+
+_DAO_LIST = "superset.daos.dashboard.DashboardDAO.list"
+_BYPASS = "superset.mcp_service.mcp_core.skip_visibility_filter"
+
+
+@pytest.fixture
+def mcp_server() -> object:
+    return mcp
+
+
+@pytest.fixture(autouse=True)
+def mock_auth() -> Iterator[Mock]:
+    with patch("superset.mcp_service.auth.get_user_from_request") as mock_get_user:
+        mock_user = Mock()
+        mock_user.id = 1
+        mock_user.username = "admin"
+        mock_get_user.return_value = mock_user
+        yield mock_get_user
+
+
+def _trashed_dashboard_row() -> Mock:
+    row = Mock(
+        spec=[
+            "id",
+            "dashboard_title",
+            "slug",
+            "published",
+            "changed_on",
+            "created_on",
+            "uuid",
+            "deleted_at",
+        ]
+    )
+    row.id = 1
+    row.dashboard_title = "Trashed Dashboard"
+    row.slug = None
+    row.published = False
+    row.changed_on = datetime(2026, 6, 1)
+    row.created_on = datetime(2026, 5, 1)
+    row.uuid = UUID("aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee")
+    row.deleted_at = datetime(2026, 7, 1)
+    return row
+
+
+@patch(_DAO_LIST)
+@pytest.mark.asyncio
+async def test_list_dashboards_deleted_state_only_passes_custom_filter(
+    mock_list: Mock, mcp_server: object
+) -> None:
+    mock_list.return_value = ([], 0)
+
+    async with Client(mcp_server) as client:
+        await client.call_tool(
+            "list_dashboards", {"request": {"deleted_state": "only"}}
+        )
+
+    kwargs = mock_list.call_args.kwargs
+    assert "deleted_state" in (kwargs.get("custom_filters") or {})
+    assert "deleted_at" in kwargs["columns"]
+
+
+@patch(_BYPASS)
+@patch(_DAO_LIST)
+@pytest.mark.asyncio
+async def test_list_dashboards_deleted_state_wraps_visibility_bypass(
+    mock_list: Mock, mock_bypass: MagicMock, mcp_server: object
+) -> None:
+    from superset.models.dashboard import Dashboard
+
+    mock_list.return_value = ([], 0)
+    mock_bypass.return_value.__enter__ = Mock(return_value=None)
+    mock_bypass.return_value.__exit__ = Mock(return_value=False)
+
+    async with Client(mcp_server) as client:
+        await client.call_tool(
+            "list_dashboards", {"request": {"deleted_state": "include"}}
+        )
+
+    mock_bypass.assert_called_once()
+    assert Dashboard in mock_bypass.call_args.args
+
+
+@patch(_DAO_LIST)
+@pytest.mark.asyncio
+async def test_list_dashboards_deleted_state_serializes_deleted_at(
+    mock_list: Mock, mcp_server: object
+) -> None:
+    mock_list.return_value = ([_trashed_dashboard_row()], 1)
+
+    async with Client(mcp_server) as client:
+        result = await client.call_tool(
+            "list_dashboards", {"request": {"deleted_state": "only"}}
+        )
+
+    data = json.loads(result.content[0].text)

Review Comment:
   Declining, standing rationale: constants and locals with inferable types are unannotated across this codebase (the same patterns appear in all seven in-tree chart plugins and throughout mcp_service); mypy passes. Identical future findings will be declined the same way.



##########
tests/unit_tests/mcp_service/test_mcp_core.py:
##########
@@ -312,3 +312,19 @@ def test_explicit_title_column_overrides_dao_attribute() -> None:
 )
 def test_slugify_handles_edge_cases(identifier: str, expected_slug: str) -> None:
     assert _slugify(identifier) == expected_slug
+
+
+def test_deleted_state_bound_filter_delegates_bound_value() -> None:
+    """The adapter passed to DAO custom_filters must forward the bound
+    deleted_state value — BaseDAO.list invokes custom filters with
+    ``apply(query, None)``, which the FAB filter would treat as 'live only'."""
+    from unittest.mock import Mock
+
+    from superset.mcp_service.mcp_core import DeletedStateBoundFilter
+
+    inner = Mock()
+    inner.apply.return_value = "filtered-query"
+    bound = DeletedStateBoundFilter(inner, "only", model=Mock)

Review Comment:
   Declining, standing rationale: constants and locals with inferable types are unannotated across this codebase (the same patterns appear in all seven in-tree chart plugins and throughout mcp_service); mypy passes. Identical future findings will be declined the same way.



##########
superset/mcp_service/mcp_core.py:
##########
@@ -326,17 +381,40 @@ def run_tool(
 
         self._validate_order_column(order_column)
 
+        deleted_state_bound = self._build_deleted_state_filter(deleted_state)

Review Comment:
   Declining, standing rationale: constants and locals with inferable types are unannotated across this codebase (the same patterns appear in all seven in-tree chart plugins and throughout mcp_service); mypy passes. Identical future findings will be declined the same way.



##########
superset/mcp_service/mcp_core.py:
##########
@@ -326,17 +381,40 @@ def run_tool(
 
         self._validate_order_column(order_column)
 
+        deleted_state_bound = self._build_deleted_state_filter(deleted_state)
+        if deleted_state_bound is not None:
+            # Trashed rows must be distinguishable from live ones (matters in
+            # "include" mode), so force deleted_at into the loaded columns
+            # and the serialization allowlist.
+            for column_list in (columns_requested, columns_to_load):
+                if "deleted_at" not in column_list:
+                    column_list.append("deleted_at")
+
         # Query the DAO
         items: List[Any]
-        items, total_count = self._call_dao_list(
-            filters=filters,
-            order_column=order_column or "changed_on",
-            order_direction=str(order_direction or "desc"),
-            page=page,
-            page_size=page_size,
-            search=search,
-            columns_to_load=columns_to_load,
-        )
+        dao_kwargs = {
+            "filters": filters,
+            "order_column": order_column or "changed_on",
+            "order_direction": str(order_direction or "desc"),
+            "page": page,
+            "page_size": page_size,
+            "search": search,
+            "columns_to_load": columns_to_load,

Review Comment:
   Declining, standing rationale: constants and locals with inferable types are unannotated across this codebase (the same patterns appear in all seven in-tree chart plugins and throughout mcp_service); mypy passes. Identical future findings will be declined the same way.



-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] feat(mcp): deleted_state trash listing for list_charts and list_dashboards [superset]

Posted by "rusackas (via GitHub)" <gi...@apache.org>.
rusackas commented on PR #41855:
URL: https://github.com/apache/superset/pull/41855#issuecomment-4986034078

   @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. 


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] feat(mcp): deleted_state trash listing for list_charts and list_dashboards [superset]

Posted by "codeant-ai-for-open-source[bot] (via GitHub)" <gi...@apache.org>.
codeant-ai-for-open-source[bot] commented on code in PR #41855:
URL: https://github.com/apache/superset/pull/41855#discussion_r3575421023


##########
tests/unit_tests/mcp_service/test_mcp_core.py:
##########
@@ -312,3 +316,70 @@ def test_explicit_title_column_overrides_dao_attribute() -> None:
 )
 def test_slugify_handles_edge_cases(identifier: str, expected_slug: str) -> None:
     assert _slugify(identifier) == expected_slug
+
+
+def test_deleted_state_bound_filter_delegates_bound_value() -> None:
+    """The adapter passed to DAO custom_filters must forward the bound
+    deleted_state value — BaseDAO.list invokes custom filters with
+    ``apply(query, None)``, which the FAB filter would treat as 'live only'."""
+    from unittest.mock import Mock
+
+    from superset.mcp_service.mcp_core import DeletedStateBoundFilter
+
+    inner = Mock()
+    inner.apply.return_value = "filtered-query"
+    bound = DeletedStateBoundFilter(inner, "only", model=Mock)
+
+    assert bound.apply("query", None) == "filtered-query"
+    inner.apply.assert_called_once_with("query", "only")
+
+
+def _build_list_core(
+    deleted_state_filter: type | None = None,
+) -> "ModelListCore[Any]":
+    """Minimal ModelListCore for exercising _build_deleted_state_filter."""
+    from unittest.mock import MagicMock
+
+    from pydantic import BaseModel
+
+    class _Out(BaseModel):
+        pass
+
+    return ModelListCore(
+        dao_class=MagicMock(),
+        output_schema=_Out,
+        item_serializer=lambda obj, cols: None,

Review Comment:
   **Suggestion:** Replace the untyped lambda with a typed callable so its parameters are explicitly annotated. [custom_rule]
   
   **Severity Level:** Minor 🧹
   <details>
   <summary><b>Why it matters? ⭐ </b></summary>
   
   The new test helper passes an untyped lambda into `ModelListCore` where the parameters can clearly be annotated. This matches the Python type-hints rule because the introduced callable omits explicit parameter types.
   </details>
   <details>
   <summary><b>Rule source 📖 </b></summary>
   
   .cursor/rules/dev-standard.mdc (line 28)
   </details>
   
   [![Fix in Cursor](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-cursor-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=3c7e686495364914ba024b43faf635c1&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset) [![Fix in VSCode Claude](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-vscode-claude-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=3c7e686495364914ba024b43faf635c1&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
   
   *(Use Cmd/Ctrl + Click for best experience)*
   <details>
   <summary><b>Prompt for AI Agent 🤖 </b></summary>
   
   ```mdx
   This is a comment left during a code review.
   
   **Path:** tests/unit_tests/mcp_service/test_mcp_core.py
   **Line:** 351:351
   **Comment:**
   	*Custom Rule: Replace the untyped lambda with a typed callable so its parameters are explicitly annotated.
   
   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
   ```
   </details>
   <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41855&comment_hash=b76d09b7f9140580149c8e3d29d274b1a0f162b321c9f9290619886b7dfcc0ff&reaction=like'>👍</a> | <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41855&comment_hash=b76d09b7f9140580149c8e3d29d274b1a0f162b321c9f9290619886b7dfcc0ff&reaction=dislike'>👎</a>



##########
tests/unit_tests/mcp_service/chart/tool/test_list_charts_deleted_state.py:
##########
@@ -0,0 +1,171 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+"""Unit tests for list_charts ``deleted_state`` trash listing.
+
+The deleted_state param opts the list query into surfacing soft-deleted
+charts: the session-scoped visibility bypass wraps the DAO call, the REST
+``ChartDeletedStateFilter`` (which owns the restore-audience scoping) is
+passed through as a DAO custom filter, and ``deleted_at`` is forced into the
+loaded columns so trashed rows are distinguishable in the response.
+"""
+
+from collections.abc import Iterator
+from datetime import datetime
+from unittest.mock import MagicMock, Mock, patch
+from uuid import UUID
+
+import pytest
+from fastmcp import Client
+from fastmcp.exceptions import ToolError
+
+from superset.mcp_service.app import mcp
+from superset.utils import json
+
+_DAO_LIST = "superset.daos.chart.ChartDAO.list"

Review Comment:
   **Suggestion:** Add an explicit type annotation to this module-level constant so it complies with the type-hint requirement for annotatable variables. [custom_rule]
   
   **Severity Level:** Minor 🧹
   <details>
   <summary><b>Why it matters? ⭐ </b></summary>
   
   The module-level constant is introduced without a type annotation even though it is a clearly annotatable string variable. This matches the Python type-hint rule for relevant variables in new code.
   </details>
   <details>
   <summary><b>Rule source 📖 </b></summary>
   
   .cursor/rules/dev-standard.mdc (line 28)
   </details>
   
   [![Fix in Cursor](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-cursor-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=f3da2634459d4499b993837e9ce85532&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset) [![Fix in VSCode Claude](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-vscode-claude-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=f3da2634459d4499b993837e9ce85532&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
   
   *(Use Cmd/Ctrl + Click for best experience)*
   <details>
   <summary><b>Prompt for AI Agent 🤖 </b></summary>
   
   ```mdx
   This is a comment left during a code review.
   
   **Path:** tests/unit_tests/mcp_service/chart/tool/test_list_charts_deleted_state.py
   **Line:** 39:39
   **Comment:**
   	*Custom Rule: Add an explicit type annotation to this module-level constant so it complies with the type-hint requirement for annotatable 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
   ```
   </details>
   <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41855&comment_hash=841dc5d52a43a1cbf4f7e527465013d74b2b992204e6770061acaa96a6019b42&reaction=like'>👍</a> | <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41855&comment_hash=841dc5d52a43a1cbf4f7e527465013d74b2b992204e6770061acaa96a6019b42&reaction=dislike'>👎</a>



-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] feat(mcp): deleted_state trash listing for list_charts and list_dashboards [superset]

Posted by "netlify[bot] (via GitHub)" <gi...@apache.org>.
netlify[bot] commented on PR #41855:
URL: https://github.com/apache/superset/pull/41855#issuecomment-4905733552

   ### <span aria-hidden="true">✅</span> Deploy Preview for *superset-docs-preview* ready!
   
   
   |  Name | Link |
   |:-:|------------------------|
   |<span aria-hidden="true">🔨</span> Latest commit | 8eb3b5800c8eac2a2f40f045743dcfecda2cdaee |
   |<span aria-hidden="true">🔍</span> Latest deploy log | https://app.netlify.com/projects/superset-docs-preview/deploys/6a4d20ed5770f400084058a3 |
   |<span aria-hidden="true">😎</span> Deploy Preview | [https://deploy-preview-41855--superset-docs-preview.netlify.app](https://deploy-preview-41855--superset-docs-preview.netlify.app) |
   |<span aria-hidden="true">📱</span> Preview on mobile | <details><summary> Toggle QR Code... </summary><br /><br />![QR Code](https://app.netlify.com/qr-code/eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1cmwiOiJodHRwczovL2RlcGxveS1wcmV2aWV3LTQxODU1LS1zdXBlcnNldC1kb2NzLXByZXZpZXcubmV0bGlmeS5hcHAifQ.aeCz-Bw8QtYmYI7DHLLuTv-TPhDXtjMlNRQ14DHXid4)<br /><br />_Use your smartphone camera to open QR code link._</details> |
   |<span aria-hidden="true">🤖</span> Make changes | [Run an agent on this branch](https://app.netlify.com/projects/superset-docs-preview/agent-runs#DcoxDoAgDADAv3SW2CiK8Qc-o9oSSVAIdDHGv8t2w72QS7qywgrQwV7oPs5mL6T9dWTDEkWFTVVSMTFUNT5EldI2S47p2bj9mSwPKDw5h94i4mJxWmiE7wc) |
   ---
   <!-- [superset-docs-preview Preview](https://deploy-preview-41855--superset-docs-preview.netlify.app) -->
   _To edit notification comments on pull requests, go to your [Netlify project configuration](https://app.netlify.com/projects/superset-docs-preview/configuration/notifications#deploy-notifications)._


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] feat(mcp): deleted_state trash listing for list_charts and list_dashboards [superset]

Posted by "codeant-ai-for-open-source[bot] (via GitHub)" <gi...@apache.org>.
codeant-ai-for-open-source[bot] commented on code in PR #41855:
URL: https://github.com/apache/superset/pull/41855#discussion_r3565413121


##########
tests/unit_tests/mcp_service/dashboard/tool/test_list_dashboards_deleted_state.py:
##########
@@ -0,0 +1,131 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+"""Unit tests for list_dashboards ``deleted_state`` trash listing.
+
+Mirrors the list_charts deleted_state tests: DAO custom filter pass-through,
+session-scoped visibility bypass around the DAO call, and ``deleted_at``
+forced into loaded columns and the serialized response.
+"""
+
+from datetime import datetime
+from unittest.mock import MagicMock, Mock, patch
+from uuid import UUID
+
+import pytest
+from fastmcp import Client
+
+from superset.mcp_service.app import mcp
+from superset.utils import json
+
+_DAO_LIST = "superset.daos.dashboard.DashboardDAO.list"
+_BYPASS = "superset.mcp_service.mcp_core.skip_visibility_filter"
+
+
+@pytest.fixture
+def mcp_server() -> object:
+    return mcp
+
+
+@pytest.fixture(autouse=True)

Review Comment:
   **Suggestion:** Add an explicit return type annotation to this fixture function (for example an iterator/generator-based fixture return type) to satisfy the required type-hint rule. [custom_rule]
   
   **Severity Level:** Minor 🧹
   <details>
   <summary><b>Why it matters? ⭐ </b></summary>
   
   The new fixture function `mock_auth` is introduced without any return type annotation, which matches the rule requiring type hints on new or modified Python functions where applicable.
   </details>
   <details>
   <summary><b>Rule source 📖 </b></summary>
   
   .cursor/rules/dev-standard.mdc (line 28)
   </details>
   
   [![Fix in Cursor](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-cursor-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=8f8f4fec092647b2971457844f7835a6&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset) [![Fix in VSCode Claude](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-vscode-claude-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=8f8f4fec092647b2971457844f7835a6&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
   
   *(Use Cmd/Ctrl + Click for best experience)*
   <details>
   <summary><b>Prompt for AI Agent 🤖 </b></summary>
   
   ```mdx
   This is a comment left during a code review.
   
   **Path:** tests/unit_tests/mcp_service/dashboard/tool/test_list_dashboards_deleted_state.py
   **Line:** 44:44
   **Comment:**
   	*Custom Rule: Add an explicit return type annotation to this fixture function (for example an iterator/generator-based fixture return type) to satisfy the required type-hint rule.
   
   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
   ```
   </details>
   <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41855&comment_hash=ed6a01aaf1b2005af5aa02b765916aa84cf8c66ec7dfe22ca46cb215e0fd3f11&reaction=like'>👍</a> | <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41855&comment_hash=ed6a01aaf1b2005af5aa02b765916aa84cf8c66ec7dfe22ca46cb215e0fd3f11&reaction=dislike'>👎</a>



##########
tests/unit_tests/mcp_service/test_mcp_core.py:
##########
@@ -312,3 +312,19 @@ def test_explicit_title_column_overrides_dao_attribute() -> None:
 )
 def test_slugify_handles_edge_cases(identifier: str, expected_slug: str) -> None:
     assert _slugify(identifier) == expected_slug
+
+
+def test_deleted_state_bound_filter_delegates_bound_value() -> None:
+    """The adapter passed to DAO custom_filters must forward the bound
+    deleted_state value — BaseDAO.list invokes custom filters with
+    ``apply(query, None)``, which the FAB filter would treat as 'live only'."""
+    from unittest.mock import Mock
+
+    from superset.mcp_service.mcp_core import DeletedStateBoundFilter
+
+    inner = Mock()

Review Comment:
   **Suggestion:** Add an explicit type annotation for this mock variable to comply with the type-hint requirement for new code. [custom_rule]
   
   **Severity Level:** Minor 🧹
   <details>
   <summary><b>Why it matters? ⭐ </b></summary>
   
   This is new Python code in the test file and the local variable can be annotated, so it matches the type-hint rule for newly added code that omits an available type hint.
   </details>
   <details>
   <summary><b>Rule source 📖 </b></summary>
   
   .cursor/rules/dev-standard.mdc (line 28)
   </details>
   
   [![Fix in Cursor](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-cursor-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=a5411b43c37544a28f10915bd5191acb&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset) [![Fix in VSCode Claude](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-vscode-claude-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=a5411b43c37544a28f10915bd5191acb&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
   
   *(Use Cmd/Ctrl + Click for best experience)*
   <details>
   <summary><b>Prompt for AI Agent 🤖 </b></summary>
   
   ```mdx
   This is a comment left during a code review.
   
   **Path:** tests/unit_tests/mcp_service/test_mcp_core.py
   **Line:** 325:325
   **Comment:**
   	*Custom Rule: Add an explicit type annotation for this mock variable to comply with the type-hint requirement for new code.
   
   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
   ```
   </details>
   <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41855&comment_hash=81fd4bd402457a2fadc59095d498285c82878a136452f45498534ccb81d4a0f3&reaction=like'>👍</a> | <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41855&comment_hash=81fd4bd402457a2fadc59095d498285c82878a136452f45498534ccb81d4a0f3&reaction=dislike'>👎</a>



##########
tests/unit_tests/mcp_service/test_mcp_core.py:
##########
@@ -312,3 +312,19 @@ def test_explicit_title_column_overrides_dao_attribute() -> None:
 )
 def test_slugify_handles_edge_cases(identifier: str, expected_slug: str) -> None:
     assert _slugify(identifier) == expected_slug
+
+
+def test_deleted_state_bound_filter_delegates_bound_value() -> None:
+    """The adapter passed to DAO custom_filters must forward the bound
+    deleted_state value — BaseDAO.list invokes custom filters with
+    ``apply(query, None)``, which the FAB filter would treat as 'live only'."""
+    from unittest.mock import Mock
+
+    from superset.mcp_service.mcp_core import DeletedStateBoundFilter
+
+    inner = Mock()
+    inner.apply.return_value = "filtered-query"
+    bound = DeletedStateBoundFilter(inner, "only", model=Mock)

Review Comment:
   **Suggestion:** Add a concrete type annotation for this bound filter variable so the new test code remains fully typed. [custom_rule]
   
   **Severity Level:** Minor 🧹
   <details>
   <summary><b>Why it matters? ⭐ </b></summary>
   
   This is a newly added local variable in Python code and it could be annotated with its concrete type, so the omission of a type hint is a real match for the rule.
   </details>
   <details>
   <summary><b>Rule source 📖 </b></summary>
   
   .cursor/rules/dev-standard.mdc (line 28)
   </details>
   
   [![Fix in Cursor](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-cursor-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=1955fd5970954c14b57120b124219b39&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset) [![Fix in VSCode Claude](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-vscode-claude-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=1955fd5970954c14b57120b124219b39&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
   
   *(Use Cmd/Ctrl + Click for best experience)*
   <details>
   <summary><b>Prompt for AI Agent 🤖 </b></summary>
   
   ```mdx
   This is a comment left during a code review.
   
   **Path:** tests/unit_tests/mcp_service/test_mcp_core.py
   **Line:** 327:327
   **Comment:**
   	*Custom Rule: Add a concrete type annotation for this bound filter variable so the new test code remains fully 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
   ```
   </details>
   <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41855&comment_hash=a15ede5d4ec0690d7ea5ba682b5db3c15e49ea480c9a06a8a985c2b8f996c5b9&reaction=like'>👍</a> | <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41855&comment_hash=a15ede5d4ec0690d7ea5ba682b5db3c15e49ea480c9a06a8a985c2b8f996c5b9&reaction=dislike'>👎</a>



##########
tests/unit_tests/mcp_service/chart/tool/test_list_charts_deleted_state.py:
##########
@@ -0,0 +1,170 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+"""Unit tests for list_charts ``deleted_state`` trash listing.
+
+The deleted_state param opts the list query into surfacing soft-deleted
+charts: the session-scoped visibility bypass wraps the DAO call, the REST
+``ChartDeletedStateFilter`` (which owns the restore-audience scoping) is
+passed through as a DAO custom filter, and ``deleted_at`` is forced into the
+loaded columns so trashed rows are distinguishable in the response.
+"""
+
+from datetime import datetime
+from unittest.mock import MagicMock, Mock, patch
+from uuid import UUID
+
+import pytest
+from fastmcp import Client
+from fastmcp.exceptions import ToolError
+
+from superset.mcp_service.app import mcp
+from superset.utils import json
+
+_DAO_LIST = "superset.daos.chart.ChartDAO.list"
+_BYPASS = "superset.mcp_service.mcp_core.skip_visibility_filter"
+
+
+@pytest.fixture
+def mcp_server() -> object:
+    return mcp
+
+
+@pytest.fixture(autouse=True)
+def mock_auth():

Review Comment:
   **Suggestion:** Add an explicit return type hint to this fixture function (for example, an iterator/generator of the mocked auth object) so it complies with the required typing rule. [custom_rule]
   
   **Severity Level:** Minor 🧹
   <details>
   <summary><b>Why it matters? ⭐ </b></summary>
   
   The fixture function `mock_auth` has no return type annotation, and the custom rule requires new or modified Python functions to include type hints when they can be annotated. This is a real violation in the added test file.
   </details>
   <details>
   <summary><b>Rule source 📖 </b></summary>
   
   .cursor/rules/dev-standard.mdc (line 28)
   </details>
   
   [![Fix in Cursor](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-cursor-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=286c7d777b324f419faa18c1e4620771&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset) [![Fix in VSCode Claude](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-vscode-claude-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=286c7d777b324f419faa18c1e4620771&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
   
   *(Use Cmd/Ctrl + Click for best experience)*
   <details>
   <summary><b>Prompt for AI Agent 🤖 </b></summary>
   
   ```mdx
   This is a comment left during a code review.
   
   **Path:** tests/unit_tests/mcp_service/chart/tool/test_list_charts_deleted_state.py
   **Line:** 48:48
   **Comment:**
   	*Custom Rule: Add an explicit return type hint to this fixture function (for example, an iterator/generator of the mocked auth object) so it complies with the required typing rule.
   
   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
   ```
   </details>
   <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41855&comment_hash=700dd03823731a60510732babb002748f15fcf697f552a4894e05f9cfa04ed91&reaction=like'>👍</a> | <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41855&comment_hash=700dd03823731a60510732babb002748f15fcf697f552a4894e05f9cfa04ed91&reaction=dislike'>👎</a>



-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] feat(mcp): deleted_state trash listing for list_charts and list_dashboards [superset]

Posted by "gkneighb (via GitHub)" <gi...@apache.org>.
gkneighb commented on PR #41855:
URL: https://github.com/apache/superset/pull/41855#issuecomment-4987119365

   Nothing outstanding — all review threads are resolved and CI is green. The two findings from the review pass (defensive-branch coverage in `_build_deleted_state_filter` and dashboard/chart test parity) are fixed at HEAD, and the type-annotation threads were declined with the standing rationale you've seen on the sibling PRs. Ready to merge; no follow-up needed. Thanks!


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] feat(mcp): deleted_state trash listing for list_charts and list_dashboards [superset]

Posted by "rusackas (via GitHub)" <gi...@apache.org>.
rusackas merged PR #41855:
URL: https://github.com/apache/superset/pull/41855


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] feat(mcp): deleted_state trash listing for list_charts and list_dashboards [superset]

Posted by "gkneighb (via GitHub)" <gi...@apache.org>.
gkneighb commented on code in PR #41855:
URL: https://github.com/apache/superset/pull/41855#discussion_r3575562748


##########
tests/unit_tests/mcp_service/test_mcp_core.py:
##########
@@ -312,3 +316,70 @@ def test_explicit_title_column_overrides_dao_attribute() -> None:
 )
 def test_slugify_handles_edge_cases(identifier: str, expected_slug: str) -> None:
     assert _slugify(identifier) == expected_slug
+
+
+def test_deleted_state_bound_filter_delegates_bound_value() -> None:
+    """The adapter passed to DAO custom_filters must forward the bound
+    deleted_state value — BaseDAO.list invokes custom filters with
+    ``apply(query, None)``, which the FAB filter would treat as 'live only'."""
+    from unittest.mock import Mock
+
+    from superset.mcp_service.mcp_core import DeletedStateBoundFilter
+
+    inner = Mock()
+    inner.apply.return_value = "filtered-query"
+    bound = DeletedStateBoundFilter(inner, "only", model=Mock)
+
+    assert bound.apply("query", None) == "filtered-query"
+    inner.apply.assert_called_once_with("query", "only")
+
+
+def _build_list_core(
+    deleted_state_filter: type | None = None,
+) -> "ModelListCore[Any]":
+    """Minimal ModelListCore for exercising _build_deleted_state_filter."""
+    from unittest.mock import MagicMock
+
+    from pydantic import BaseModel
+
+    class _Out(BaseModel):
+        pass
+
+    return ModelListCore(
+        dao_class=MagicMock(),
+        output_schema=_Out,
+        item_serializer=lambda obj, cols: None,

Review Comment:
   Declining, standing rationale: constants, locals, and test lambdas with inferable types are unannotated across this codebase; mypy passes. Identical future findings will be declined the same way.



##########
tests/unit_tests/mcp_service/chart/tool/test_list_charts_deleted_state.py:
##########
@@ -0,0 +1,171 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+"""Unit tests for list_charts ``deleted_state`` trash listing.
+
+The deleted_state param opts the list query into surfacing soft-deleted
+charts: the session-scoped visibility bypass wraps the DAO call, the REST
+``ChartDeletedStateFilter`` (which owns the restore-audience scoping) is
+passed through as a DAO custom filter, and ``deleted_at`` is forced into the
+loaded columns so trashed rows are distinguishable in the response.
+"""
+
+from collections.abc import Iterator
+from datetime import datetime
+from unittest.mock import MagicMock, Mock, patch
+from uuid import UUID
+
+import pytest
+from fastmcp import Client
+from fastmcp.exceptions import ToolError
+
+from superset.mcp_service.app import mcp
+from superset.utils import json
+
+_DAO_LIST = "superset.daos.chart.ChartDAO.list"

Review Comment:
   Declining, standing rationale: constants, locals, and test lambdas with inferable types are unannotated across this codebase; mypy passes. Identical future findings will be declined the same way.



##########
tests/unit_tests/mcp_service/dashboard/tool/test_list_dashboards_deleted_state.py:
##########
@@ -0,0 +1,176 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+"""Unit tests for list_dashboards ``deleted_state`` trash listing.
+
+Mirrors the list_charts deleted_state tests: DAO custom filter pass-through,
+session-scoped visibility bypass around the DAO call, and ``deleted_at``
+forced into loaded columns and the serialized response.
+"""
+
+from collections.abc import Iterator
+from datetime import datetime
+from unittest.mock import MagicMock, Mock, patch
+from uuid import UUID
+
+import pytest
+from fastmcp import Client
+
+from superset.mcp_service.app import mcp
+from superset.utils import json
+
+_DAO_LIST = "superset.daos.dashboard.DashboardDAO.list"
+_BYPASS = "superset.mcp_service.mcp_core.skip_visibility_filter"
+
+
+@pytest.fixture
+def mcp_server() -> object:
+    return mcp
+
+
+@pytest.fixture(autouse=True)
+def mock_auth() -> Iterator[Mock]:
+    with patch("superset.mcp_service.auth.get_user_from_request") as mock_get_user:
+        mock_user = Mock()
+        mock_user.id = 1
+        mock_user.username = "admin"
+        mock_get_user.return_value = mock_user
+        yield mock_get_user
+
+
+def _trashed_dashboard_row() -> Mock:
+    row = Mock(
+        spec=[
+            "id",
+            "dashboard_title",
+            "slug",
+            "published",
+            "changed_on",
+            "created_on",
+            "uuid",
+            "deleted_at",
+        ]
+    )
+    row.id = 1
+    row.dashboard_title = "Trashed Dashboard"
+    row.slug = None
+    row.published = False
+    row.changed_on = datetime(2026, 6, 1)
+    row.created_on = datetime(2026, 5, 1)
+    row.uuid = UUID("aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee")
+    row.deleted_at = datetime(2026, 7, 1)
+    return row
+
+
+@patch(_DAO_LIST)
+@pytest.mark.asyncio
+async def test_list_dashboards_deleted_state_only_passes_custom_filter(
+    mock_list: Mock, mcp_server: object
+) -> None:
+    mock_list.return_value = ([], 0)
+
+    async with Client(mcp_server) as client:
+        await client.call_tool(
+            "list_dashboards", {"request": {"deleted_state": "only"}}
+        )
+
+    kwargs = mock_list.call_args.kwargs

Review Comment:
   Declining, standing rationale: constants, locals, and test lambdas with inferable types are unannotated across this codebase; mypy passes. Identical future findings will be declined the same way.



-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] feat(mcp): deleted_state trash listing for list_charts and list_dashboards [superset]

Posted by "codeant-ai-for-open-source[bot] (via GitHub)" <gi...@apache.org>.
codeant-ai-for-open-source[bot] commented on code in PR #41855:
URL: https://github.com/apache/superset/pull/41855#discussion_r3537879790


##########
superset/mcp_service/mcp_core.py:
##########
@@ -326,17 +381,40 @@ def run_tool(
 
         self._validate_order_column(order_column)
 
+        deleted_state_bound = self._build_deleted_state_filter(deleted_state)
+        if deleted_state_bound is not None:
+            # Trashed rows must be distinguishable from live ones (matters in
+            # "include" mode), so force deleted_at into the loaded columns
+            # and the serialization allowlist.
+            for column_list in (columns_requested, columns_to_load):
+                if "deleted_at" not in column_list:
+                    column_list.append("deleted_at")
+
         # Query the DAO
         items: List[Any]
-        items, total_count = self._call_dao_list(
-            filters=filters,
-            order_column=order_column or "changed_on",
-            order_direction=str(order_direction or "desc"),
-            page=page,
-            page_size=page_size,
-            search=search,
-            columns_to_load=columns_to_load,
-        )
+        dao_kwargs = {
+            "filters": filters,
+            "order_column": order_column or "changed_on",
+            "order_direction": str(order_direction or "desc"),
+            "page": page,
+            "page_size": page_size,
+            "search": search,
+            "columns_to_load": columns_to_load,
+        }

Review Comment:
   **Suggestion:** Add an explicit type annotation to this dictionary to satisfy the type-hint requirement for relevant local variables. [custom_rule]
   
   **Severity Level:** Minor ⚠️
   <details>
   <summary><b>Why it matters? 🤔 </b></summary>
   
   This is a newly introduced local dictionary in Python code and it has no explicit type annotation. That matches the rule requiring type hints for relevant variables that can be annotated, so the suggestion is valid.
   </details>
   <details>
   <summary><b>Rule source 📖 </b></summary>
   
   .cursor/rules/dev-standard.mdc (line 28)
   </details>
   
   [![Fix in Cursor](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-cursor-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=77966dcec1c44087b9824bad88cdd42d&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset) [![Fix in VSCode Claude](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-vscode-claude-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=77966dcec1c44087b9824bad88cdd42d&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
   
   *(Use Cmd/Ctrl + Click for best experience)*
   <details>
   <summary><b>Prompt for AI Agent 🤖 </b></summary>
   
   ```mdx
   This is a comment left during a code review.
   
   **Path:** superset/mcp_service/mcp_core.py
   **Line:** 395:403
   **Comment:**
   	*Custom Rule: Add an explicit type annotation to this dictionary to satisfy the type-hint requirement for relevant local 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
   ```
   </details>
   <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41855&comment_hash=437f04b212220406ccb563500c048b742b768f105d473ac02178b3ff1db39d8c&reaction=like'>👍</a> | <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41855&comment_hash=437f04b212220406ccb563500c048b742b768f105d473ac02178b3ff1db39d8c&reaction=dislike'>👎</a>



##########
tests/unit_tests/mcp_service/chart/tool/test_list_charts_deleted_state.py:
##########
@@ -0,0 +1,170 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+"""Unit tests for list_charts ``deleted_state`` trash listing.
+
+The deleted_state param opts the list query into surfacing soft-deleted
+charts: the session-scoped visibility bypass wraps the DAO call, the REST
+``ChartDeletedStateFilter`` (which owns the restore-audience scoping) is
+passed through as a DAO custom filter, and ``deleted_at`` is forced into the
+loaded columns so trashed rows are distinguishable in the response.
+"""
+
+from datetime import datetime
+from unittest.mock import MagicMock, Mock, patch
+from uuid import UUID
+
+import pytest
+from fastmcp import Client
+from fastmcp.exceptions import ToolError
+
+from superset.mcp_service.app import mcp
+from superset.utils import json
+
+_DAO_LIST = "superset.daos.chart.ChartDAO.list"
+_BYPASS = "superset.mcp_service.mcp_core.skip_visibility_filter"
+
+
+@pytest.fixture
+def mcp_server() -> object:
+    return mcp
+
+
+@pytest.fixture(autouse=True)

Review Comment:
   **Suggestion:** Add an explicit return type hint to this fixture function (for example, a generator/yield-compatible return annotation) to satisfy required Python typing. [custom_rule]
   
   **Severity Level:** Minor ⚠️
   <details>
   <summary><b>Why it matters? 🤔 </b></summary>
   
   The rule requires new or modified Python functions to include type hints when they can be annotated. This fixture function is defined without any return type annotation, so the suggestion correctly identifies a real violation.
   </details>
   <details>
   <summary><b>Rule source 📖 </b></summary>
   
   .cursor/rules/dev-standard.mdc (line 28)
   </details>
   
   [![Fix in Cursor](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-cursor-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=fe44ee9552824ba39e0fd166081d19a0&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset) [![Fix in VSCode Claude](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-vscode-claude-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=fe44ee9552824ba39e0fd166081d19a0&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
   
   *(Use Cmd/Ctrl + Click for best experience)*
   <details>
   <summary><b>Prompt for AI Agent 🤖 </b></summary>
   
   ```mdx
   This is a comment left during a code review.
   
   **Path:** tests/unit_tests/mcp_service/chart/tool/test_list_charts_deleted_state.py
   **Line:** 47:47
   **Comment:**
   	*Custom Rule: Add an explicit return type hint to this fixture function (for example, a generator/yield-compatible return annotation) to satisfy required Python typing.
   
   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
   ```
   </details>
   <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41855&comment_hash=b6db9934ab24d450c41c03a3bd9f7b6801378bdda36acc36b45d8355fc6e41dc&reaction=like'>👍</a> | <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41855&comment_hash=b6db9934ab24d450c41c03a3bd9f7b6801378bdda36acc36b45d8355fc6e41dc&reaction=dislike'>👎</a>



-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] feat(mcp): deleted_state trash listing for list_charts and list_dashboards [superset]

Posted by "codeant-ai-for-open-source[bot] (via GitHub)" <gi...@apache.org>.
codeant-ai-for-open-source[bot] commented on code in PR #41855:
URL: https://github.com/apache/superset/pull/41855#discussion_r3565560758


##########
tests/unit_tests/mcp_service/dashboard/tool/test_list_dashboards_deleted_state.py:
##########
@@ -0,0 +1,132 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+"""Unit tests for list_dashboards ``deleted_state`` trash listing.
+
+Mirrors the list_charts deleted_state tests: DAO custom filter pass-through,
+session-scoped visibility bypass around the DAO call, and ``deleted_at``
+forced into loaded columns and the serialized response.
+"""
+
+from collections.abc import Iterator
+from datetime import datetime
+from unittest.mock import MagicMock, Mock, patch
+from uuid import UUID
+
+import pytest
+from fastmcp import Client
+
+from superset.mcp_service.app import mcp
+from superset.utils import json
+
+_DAO_LIST = "superset.daos.dashboard.DashboardDAO.list"

Review Comment:
   ✅ **Customized review instruction saved!**
   
   **Instruction:**
   > Do not flag missing type annotations for constants and locals with inferable types in mcp_service; this pattern is intentional and mypy already passes.
   
   **Applied to:**
     - `superset/mcp_service/**`
   
   ---
   💡 *To manage or update this instruction, visit: [CodeAnt AI Settings](https://app.codeant.ai/org/settings/learnings)*



##########
tests/unit_tests/mcp_service/dashboard/tool/test_list_dashboards_deleted_state.py:
##########
@@ -0,0 +1,132 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+"""Unit tests for list_dashboards ``deleted_state`` trash listing.
+
+Mirrors the list_charts deleted_state tests: DAO custom filter pass-through,
+session-scoped visibility bypass around the DAO call, and ``deleted_at``
+forced into loaded columns and the serialized response.
+"""
+
+from collections.abc import Iterator
+from datetime import datetime
+from unittest.mock import MagicMock, Mock, patch
+from uuid import UUID
+
+import pytest
+from fastmcp import Client
+
+from superset.mcp_service.app import mcp
+from superset.utils import json
+
+_DAO_LIST = "superset.daos.dashboard.DashboardDAO.list"
+_BYPASS = "superset.mcp_service.mcp_core.skip_visibility_filter"
+
+
+@pytest.fixture
+def mcp_server() -> object:
+    return mcp
+
+
+@pytest.fixture(autouse=True)
+def mock_auth() -> Iterator[Mock]:
+    with patch("superset.mcp_service.auth.get_user_from_request") as mock_get_user:
+        mock_user = Mock()
+        mock_user.id = 1
+        mock_user.username = "admin"
+        mock_get_user.return_value = mock_user
+        yield mock_get_user
+
+
+def _trashed_dashboard_row() -> Mock:
+    row = Mock(
+        spec=[
+            "id",
+            "dashboard_title",
+            "slug",
+            "published",
+            "changed_on",
+            "created_on",
+            "uuid",
+            "deleted_at",
+        ]
+    )
+    row.id = 1
+    row.dashboard_title = "Trashed Dashboard"
+    row.slug = None
+    row.published = False
+    row.changed_on = datetime(2026, 6, 1)
+    row.created_on = datetime(2026, 5, 1)
+    row.uuid = UUID("aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee")
+    row.deleted_at = datetime(2026, 7, 1)
+    return row
+
+
+@patch(_DAO_LIST)
+@pytest.mark.asyncio
+async def test_list_dashboards_deleted_state_only_passes_custom_filter(
+    mock_list: Mock, mcp_server: object
+) -> None:
+    mock_list.return_value = ([], 0)
+
+    async with Client(mcp_server) as client:
+        await client.call_tool(
+            "list_dashboards", {"request": {"deleted_state": "only"}}
+        )
+
+    kwargs = mock_list.call_args.kwargs
+    assert "deleted_state" in (kwargs.get("custom_filters") or {})
+    assert "deleted_at" in kwargs["columns"]
+
+
+@patch(_BYPASS)
+@patch(_DAO_LIST)
+@pytest.mark.asyncio
+async def test_list_dashboards_deleted_state_wraps_visibility_bypass(
+    mock_list: Mock, mock_bypass: MagicMock, mcp_server: object
+) -> None:
+    from superset.models.dashboard import Dashboard
+
+    mock_list.return_value = ([], 0)
+    mock_bypass.return_value.__enter__ = Mock(return_value=None)
+    mock_bypass.return_value.__exit__ = Mock(return_value=False)
+
+    async with Client(mcp_server) as client:
+        await client.call_tool(
+            "list_dashboards", {"request": {"deleted_state": "include"}}
+        )
+
+    mock_bypass.assert_called_once()
+    assert Dashboard in mock_bypass.call_args.args
+
+
+@patch(_DAO_LIST)
+@pytest.mark.asyncio
+async def test_list_dashboards_deleted_state_serializes_deleted_at(
+    mock_list: Mock, mcp_server: object
+) -> None:
+    mock_list.return_value = ([_trashed_dashboard_row()], 1)
+
+    async with Client(mcp_server) as client:
+        result = await client.call_tool(
+            "list_dashboards", {"request": {"deleted_state": "only"}}
+        )
+
+    data = json.loads(result.content[0].text)

Review Comment:
   ✅ **Customized review instruction saved!**
   
   **Instruction:**
   > Do not flag unannotated locals or constants when their type is trivially inferable and the codebase's type checks already pass.
   
   **Applied to:**
     - `**/*.py`
   
   ---
   💡 *To manage or update this instruction, visit: [CodeAnt AI Settings](https://app.codeant.ai/org/settings/learnings)*



##########
tests/unit_tests/mcp_service/test_mcp_core.py:
##########
@@ -312,3 +312,19 @@ def test_explicit_title_column_overrides_dao_attribute() -> None:
 )
 def test_slugify_handles_edge_cases(identifier: str, expected_slug: str) -> None:
     assert _slugify(identifier) == expected_slug
+
+
+def test_deleted_state_bound_filter_delegates_bound_value() -> None:
+    """The adapter passed to DAO custom_filters must forward the bound
+    deleted_state value — BaseDAO.list invokes custom filters with
+    ``apply(query, None)``, which the FAB filter would treat as 'live only'."""
+    from unittest.mock import Mock
+
+    from superset.mcp_service.mcp_core import DeletedStateBoundFilter
+
+    inner = Mock()
+    inner.apply.return_value = "filtered-query"
+    bound = DeletedStateBoundFilter(inner, "only", model=Mock)

Review Comment:
   ✅ **Customized review instruction saved!**
   
   **Instruction:**
   > Do not flag Python local variables or constants with inferable types for missing type annotations when the codebase already follows that pattern and mypy passes.
   
   **Applied to:**
     - `**/*.py`
   
   ---
   💡 *To manage or update this instruction, visit: [CodeAnt AI Settings](https://app.codeant.ai/org/settings/learnings)*



##########
superset/mcp_service/mcp_core.py:
##########
@@ -326,17 +381,40 @@ def run_tool(
 
         self._validate_order_column(order_column)
 
+        deleted_state_bound = self._build_deleted_state_filter(deleted_state)

Review Comment:
   ✅ **Customized review instruction saved!**
   
   **Instruction:**
   > Do not flag unannotated locals or constants when their types are clearly inferable; this codebase intentionally leaves such variables unannotated and mypy passes.
   
   **Applied to:**
     - `superset/mcp_service/**`
   
   ---
   💡 *To manage or update this instruction, visit: [CodeAnt AI Settings](https://app.codeant.ai/org/settings/learnings)*



##########
superset/mcp_service/mcp_core.py:
##########
@@ -326,17 +381,40 @@ def run_tool(
 
         self._validate_order_column(order_column)
 
+        deleted_state_bound = self._build_deleted_state_filter(deleted_state)
+        if deleted_state_bound is not None:
+            # Trashed rows must be distinguishable from live ones (matters in
+            # "include" mode), so force deleted_at into the loaded columns
+            # and the serialization allowlist.
+            for column_list in (columns_requested, columns_to_load):
+                if "deleted_at" not in column_list:
+                    column_list.append("deleted_at")
+
         # Query the DAO
         items: List[Any]
-        items, total_count = self._call_dao_list(
-            filters=filters,
-            order_column=order_column or "changed_on",
-            order_direction=str(order_direction or "desc"),
-            page=page,
-            page_size=page_size,
-            search=search,
-            columns_to_load=columns_to_load,
-        )
+        dao_kwargs = {
+            "filters": filters,
+            "order_column": order_column or "changed_on",
+            "order_direction": str(order_direction or "desc"),
+            "page": page,
+            "page_size": page_size,
+            "search": search,
+            "columns_to_load": columns_to_load,

Review Comment:
   ✅ **Customized review instruction saved!**
   
   **Instruction:**
   > Do not require explicit type annotations for inferable local variables or constants in Python code when the existing type is clear and mypy passes.
   
   **Applied to:**
     - `**/*.py`
   
   ---
   💡 *To manage or update this instruction, visit: [CodeAnt AI Settings](https://app.codeant.ai/org/settings/learnings)*



-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] feat(mcp): deleted_state trash listing for list_charts and list_dashboards [superset]

Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #41855:
URL: https://github.com/apache/superset/pull/41855#issuecomment-4949982390

   AI Code Review is in progress (usually takes 3 to 15 minutes unless it's a very large PR).
   
   <details>
   <summary>
   Bito Usage Guide
   </summary>
   
   **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 <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/available-commands" target="_blank" rel="noopener noreferrer">documentation</a> for additional commands.
         
   **Configuration**
   
   This repository uses `Superset` You can customize the agent settings <a href="https://alpha.bito.ai/home/ai-agents/code-review-agent" target="_blank" rel="noopener noreferrer">here</a> or contact your Bito workspace admin at evan@preset.io.
         
   **Documentation & Help**
   - <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/getting-started/install-run-using-bito-cloud/create-or-customize-an-agent-instance" target="_blank" rel="noopener noreferrer">Customize agent settings</a>
   - <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/implementing-custom-code-review-rules" target="_blank" rel="noopener noreferrer">Review rules</a>
   - <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent" target="_blank" rel="noopener noreferrer">General documentation</a>
   - <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/faqs" target="_blank" rel="noopener noreferrer">FAQ</a>
   
   </details>
   


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] feat(mcp): deleted_state trash listing for list_charts and list_dashboards [superset]

Posted by "codeant-ai-for-open-source[bot] (via GitHub)" <gi...@apache.org>.
codeant-ai-for-open-source[bot] commented on code in PR #41855:
URL: https://github.com/apache/superset/pull/41855#discussion_r3537877939


##########
tests/unit_tests/mcp_service/dashboard/tool/test_list_dashboards_deleted_state.py:
##########
@@ -0,0 +1,131 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+"""Unit tests for list_dashboards ``deleted_state`` trash listing.
+
+Mirrors the list_charts deleted_state tests: DAO custom filter pass-through,
+session-scoped visibility bypass around the DAO call, and ``deleted_at``
+forced into loaded columns and the serialized response.
+"""
+
+from datetime import datetime
+from unittest.mock import MagicMock, Mock, patch
+from uuid import UUID
+
+import pytest
+from fastmcp import Client
+
+from superset.mcp_service.app import mcp
+from superset.utils import json
+
+_DAO_LIST = "superset.daos.dashboard.DashboardDAO.list"
+_BYPASS = "superset.mcp_service.mcp_core.skip_visibility_filter"
+
+
+@pytest.fixture
+def mcp_server() -> object:
+    return mcp
+
+
+@pytest.fixture(autouse=True)
+def mock_auth():

Review Comment:
   **Suggestion:** Add an explicit return type hint to this fixture function so it complies with the required type-annotation rule. [custom_rule]
   
   **Severity Level:** Minor ⚠️
   <details>
   <summary><b>Why it matters? 🤔 </b></summary>
   
   The new fixture function `mock_auth` omits a return type annotation, which violates the Python type-hint requirement for newly added or modified functions that can be annotated.
   </details>
   <details>
   <summary><b>Rule source 📖 </b></summary>
   
   .cursor/rules/dev-standard.mdc (line 28)
   </details>
   
   [![Fix in Cursor](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-cursor-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=26d143e6ca494439af6f7018328226a3&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset) [![Fix in VSCode Claude](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-vscode-claude-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=26d143e6ca494439af6f7018328226a3&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
   
   *(Use Cmd/Ctrl + Click for best experience)*
   <details>
   <summary><b>Prompt for AI Agent 🤖 </b></summary>
   
   ```mdx
   This is a comment left during a code review.
   
   **Path:** tests/unit_tests/mcp_service/dashboard/tool/test_list_dashboards_deleted_state.py
   **Line:** 45:45
   **Comment:**
   	*Custom Rule: Add an explicit return type hint to this fixture function so it complies with the required type-annotation rule.
   
   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
   ```
   </details>
   <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41855&comment_hash=7c3134eb661cd89747a450a1865c2b6c197970f258d752f43a921bd828035ba8&reaction=like'>👍</a> | <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41855&comment_hash=7c3134eb661cd89747a450a1865c2b6c197970f258d752f43a921bd828035ba8&reaction=dislike'>👎</a>



-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] feat(mcp): deleted_state trash listing for list_charts and list_dashboards [superset]

Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #41855:
URL: https://github.com/apache/superset/pull/41855#issuecomment-4905731951

   <!-- Bito Reply -->
   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: `def mock_auth() -> Any:`. 
   
   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**
   ```
   @pytest.fixture
   def mock_auth() -> Any:
       # ... implementation ...
   ```


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] feat(mcp): deleted_state trash listing for list_charts and list_dashboards [superset]

Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #41855:
URL: https://github.com/apache/superset/pull/41855#issuecomment-4905716622

   AI Code Review is in progress (usually takes 3 to 15 minutes unless it's a very large PR).


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] feat(mcp): deleted_state trash listing for list_charts and list_dashboards [superset]

Posted by "codeant-ai-for-open-source[bot] (via GitHub)" <gi...@apache.org>.
codeant-ai-for-open-source[bot] commented on code in PR #41855:
URL: https://github.com/apache/superset/pull/41855#discussion_r3565555271


##########
superset/mcp_service/mcp_core.py:
##########
@@ -326,17 +381,40 @@ def run_tool(
 
         self._validate_order_column(order_column)
 
+        deleted_state_bound = self._build_deleted_state_filter(deleted_state)

Review Comment:
   **Suggestion:** Add a type annotation to this local variable so the deleted-state filter flow remains fully typed under the custom typing rule. [custom_rule]
   
   **Severity Level:** Minor 🧹
   <details>
   <summary><b>Why it matters? ⭐ </b></summary>
   
   This modified local variable is also type-annotatable, but it is currently unannotated, which fits the custom rule requiring type hints on relevant variables.
   </details>
   <details>
   <summary><b>Rule source 📖 </b></summary>
   
   .cursor/rules/dev-standard.mdc (line 28)
   </details>
   
   [![Fix in Cursor](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-cursor-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=b099181bc16448e487eb708ab6e8b446&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset) [![Fix in VSCode Claude](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-vscode-claude-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=b099181bc16448e487eb708ab6e8b446&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
   
   *(Use Cmd/Ctrl + Click for best experience)*
   <details>
   <summary><b>Prompt for AI Agent 🤖 </b></summary>
   
   ```mdx
   This is a comment left during a code review.
   
   **Path:** superset/mcp_service/mcp_core.py
   **Line:** 384:384
   **Comment:**
   	*Custom Rule: Add a type annotation to this local variable so the deleted-state filter flow remains fully typed under the custom typing rule.
   
   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
   ```
   </details>
   <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41855&comment_hash=bba16114c63b64553be8a16fe3197df7e32cdc19cac0a5defaa76a45a37a52a7&reaction=like'>👍</a> | <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41855&comment_hash=bba16114c63b64553be8a16fe3197df7e32cdc19cac0a5defaa76a45a37a52a7&reaction=dislike'>👎</a>



##########
superset/mcp_service/mcp_core.py:
##########
@@ -326,17 +381,40 @@ def run_tool(
 
         self._validate_order_column(order_column)
 
+        deleted_state_bound = self._build_deleted_state_filter(deleted_state)
+        if deleted_state_bound is not None:
+            # Trashed rows must be distinguishable from live ones (matters in
+            # "include" mode), so force deleted_at into the loaded columns
+            # and the serialization allowlist.
+            for column_list in (columns_requested, columns_to_load):
+                if "deleted_at" not in column_list:
+                    column_list.append("deleted_at")
+
         # Query the DAO
         items: List[Any]
-        items, total_count = self._call_dao_list(
-            filters=filters,
-            order_column=order_column or "changed_on",
-            order_direction=str(order_direction or "desc"),
-            page=page,
-            page_size=page_size,
-            search=search,
-            columns_to_load=columns_to_load,
-        )
+        dao_kwargs = {
+            "filters": filters,
+            "order_column": order_column or "changed_on",
+            "order_direction": str(order_direction or "desc"),
+            "page": page,
+            "page_size": page_size,
+            "search": search,
+            "columns_to_load": columns_to_load,

Review Comment:
   **Suggestion:** Add an explicit type annotation for this dictionary to satisfy the rule requiring type hints on relevant variables. [custom_rule]
   
   **Severity Level:** Minor 🧹
   <details>
   <summary><b>Why it matters? ⭐ </b></summary>
   
   This new local dictionary is inferably type-annotatable and currently has no explicit type hint, so it matches the rule requiring type hints on relevant variables in modified Python code.
   </details>
   <details>
   <summary><b>Rule source 📖 </b></summary>
   
   .cursor/rules/dev-standard.mdc (line 28)
   </details>
   
   [![Fix in Cursor](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-cursor-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=7670205f9e7943db92fefcce758cc334&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset) [![Fix in VSCode Claude](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-vscode-claude-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=7670205f9e7943db92fefcce758cc334&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
   
   *(Use Cmd/Ctrl + Click for best experience)*
   <details>
   <summary><b>Prompt for AI Agent 🤖 </b></summary>
   
   ```mdx
   This is a comment left during a code review.
   
   **Path:** superset/mcp_service/mcp_core.py
   **Line:** 394:402
   **Comment:**
   	*Custom Rule: Add an explicit type annotation for this dictionary to satisfy the rule requiring type hints on 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
   ```
   </details>
   <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41855&comment_hash=665fc9f928325d51df92709dce9d5e7dbdfa9692e9bb2eed98a528aa3657acdc&reaction=like'>👍</a> | <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41855&comment_hash=665fc9f928325d51df92709dce9d5e7dbdfa9692e9bb2eed98a528aa3657acdc&reaction=dislike'>👎</a>



-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] feat(mcp): deleted_state trash listing for list_charts and list_dashboards [superset]

Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #41855:
URL: https://github.com/apache/superset/pull/41855#issuecomment-4965416065

   AI Code Review is in progress (usually takes 3 to 15 minutes unless it's a very large PR).
   
   <details>
   <summary>
   Bito Usage Guide
   </summary>
   
   **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 <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/available-commands" target="_blank" rel="noopener noreferrer">documentation</a> for additional commands.
         
   **Configuration**
   
   This repository uses `Superset` You can customize the agent settings <a href="https://alpha.bito.ai/home/ai-agents/code-review-agent" target="_blank" rel="noopener noreferrer">here</a> or contact your Bito workspace admin at evan@preset.io.
         
   **Documentation & Help**
   - <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/getting-started/install-run-using-bito-cloud/create-or-customize-an-agent-instance" target="_blank" rel="noopener noreferrer">Customize agent settings</a>
   - <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/implementing-custom-code-review-rules" target="_blank" rel="noopener noreferrer">Review rules</a>
   - <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent" target="_blank" rel="noopener noreferrer">General documentation</a>
   - <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/faqs" target="_blank" rel="noopener noreferrer">FAQ</a>
   
   </details>
   


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] feat(mcp): deleted_state trash listing for list_charts and list_dashboards [superset]

Posted by "codecov[bot] (via GitHub)" <gi...@apache.org>.
codecov[bot] commented on PR #41855:
URL: https://github.com/apache/superset/pull/41855#issuecomment-4905781220

   ## [Codecov](https://app.codecov.io/gh/apache/superset/pull/41855?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
   :x: Patch coverage is `24.32432%` with `28 lines` in your changes missing coverage. Please review.
   :white_check_mark: Project coverage is 55.94%. Comparing base ([`e52240b`](https://app.codecov.io/gh/apache/superset/commit/e52240b9a602e240ab641ae806168ef3351a7e70?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`8eb3b58`](https://app.codecov.io/gh/apache/superset/commit/8eb3b5800c8eac2a2f40f045743dcfecda2cdaee?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
   :warning: Report is 30 commits behind head on master.
   
   | [Files with missing lines](https://app.codecov.io/gh/apache/superset/pull/41855?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Patch % | Lines |
   |---|---|---|
   | [superset/mcp\_service/mcp\_core.py](https://app.codecov.io/gh/apache/superset/pull/41855?src=pr&el=tree&filepath=superset%2Fmcp_service%2Fmcp_core.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3VwZXJzZXQvbWNwX3NlcnZpY2UvbWNwX2NvcmUucHk=) | 16.12% | [26 Missing :warning: ](https://app.codecov.io/gh/apache/superset/pull/41855?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   | [superset/mcp\_service/chart/tool/list\_charts.py](https://app.codecov.io/gh/apache/superset/pull/41855?src=pr&el=tree&filepath=superset%2Fmcp_service%2Fchart%2Ftool%2Flist_charts.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3VwZXJzZXQvbWNwX3NlcnZpY2UvY2hhcnQvdG9vbC9saXN0X2NoYXJ0cy5weQ==) | 0.00% | [1 Missing :warning: ](https://app.codecov.io/gh/apache/superset/pull/41855?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   | [...rset/mcp\_service/dashboard/tool/list\_dashboards.py](https://app.codecov.io/gh/apache/superset/pull/41855?src=pr&el=tree&filepath=superset%2Fmcp_service%2Fdashboard%2Ftool%2Flist_dashboards.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3VwZXJzZXQvbWNwX3NlcnZpY2UvZGFzaGJvYXJkL3Rvb2wvbGlzdF9kYXNoYm9hcmRzLnB5) | 0.00% | [1 Missing :warning: ](https://app.codecov.io/gh/apache/superset/pull/41855?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   > :exclamation:  There is a different number of reports uploaded between BASE (e52240b) and HEAD (8eb3b58). Click for more details.
   > 
   > <details><summary>HEAD has 24 uploads less than BASE</summary>
   >
   >| Flag | BASE (e52240b) | HEAD (8eb3b58) |
   >|------|------|------|
   >|python|22|2|
   >|presto|3|1|
   >|hive|3|1|
   ></details>
   
   <details><summary>Additional details and impacted files</summary>
   
   
   
   ```diff
   @@            Coverage Diff             @@
   ##           master   #41855      +/-   ##
   ==========================================
   - Coverage   64.77%   55.94%   -8.84%     
   ==========================================
     Files        2689     2690       +1     
     Lines      148945   149128     +183     
     Branches    34369    34409      +40     
   ==========================================
   - Hits        96486    83429   -13057     
   - Misses      50693    64946   +14253     
   + Partials     1766      753    -1013     
   ```
   
   | [Flag](https://app.codecov.io/gh/apache/superset/pull/41855/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | |
   |---|---|---|
   | [hive](https://app.codecov.io/gh/apache/superset/pull/41855/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `39.14% <24.32%> (-0.06%)` | :arrow_down: |
   | [mysql](https://app.codecov.io/gh/apache/superset/pull/41855/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
   | [postgres](https://app.codecov.io/gh/apache/superset/pull/41855/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
   | [presto](https://app.codecov.io/gh/apache/superset/pull/41855/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `40.67% <24.32%> (-0.06%)` | :arrow_down: |
   | [python](https://app.codecov.io/gh/apache/superset/pull/41855/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `40.73% <24.32%> (-18.60%)` | :arrow_down: |
   | [sqlite](https://app.codecov.io/gh/apache/superset/pull/41855/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
   | [unit](https://app.codecov.io/gh/apache/superset/pull/41855/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
   
   Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#carryforward-flags-in-the-pull-request-comment) to find out more.
   </details>
   
   [:umbrella: View full report in Codecov by Harness](https://app.codecov.io/gh/apache/superset/pull/41855?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).   
   :loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
   <details><summary> :rocket: New features to boost your workflow: </summary>
   
   - :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
   - :package: [JS Bundle Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
   </details>


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] feat(mcp): deleted_state trash listing for list_charts and list_dashboards [superset]

Posted by "gkneighb (via GitHub)" <gi...@apache.org>.
gkneighb commented on code in PR #41855:
URL: https://github.com/apache/superset/pull/41855#discussion_r3565553003


##########
tests/unit_tests/mcp_service/dashboard/tool/test_list_dashboards_deleted_state.py:
##########
@@ -0,0 +1,131 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+"""Unit tests for list_dashboards ``deleted_state`` trash listing.
+
+Mirrors the list_charts deleted_state tests: DAO custom filter pass-through,
+session-scoped visibility bypass around the DAO call, and ``deleted_at``
+forced into loaded columns and the serialized response.
+"""
+
+from datetime import datetime
+from unittest.mock import MagicMock, Mock, patch
+from uuid import UUID
+
+import pytest
+from fastmcp import Client
+
+from superset.mcp_service.app import mcp
+from superset.utils import json
+
+_DAO_LIST = "superset.daos.dashboard.DashboardDAO.list"
+_BYPASS = "superset.mcp_service.mcp_core.skip_visibility_filter"
+
+
+@pytest.fixture
+def mcp_server() -> object:
+    return mcp
+
+
+@pytest.fixture(autouse=True)
+def mock_auth():

Review Comment:
   Fixture annotations added in 2420e52946.



##########
tests/unit_tests/mcp_service/chart/tool/test_list_charts_deleted_state.py:
##########
@@ -0,0 +1,170 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+"""Unit tests for list_charts ``deleted_state`` trash listing.
+
+The deleted_state param opts the list query into surfacing soft-deleted
+charts: the session-scoped visibility bypass wraps the DAO call, the REST
+``ChartDeletedStateFilter`` (which owns the restore-audience scoping) is
+passed through as a DAO custom filter, and ``deleted_at`` is forced into the
+loaded columns so trashed rows are distinguishable in the response.
+"""
+
+from datetime import datetime
+from unittest.mock import MagicMock, Mock, patch
+from uuid import UUID
+
+import pytest
+from fastmcp import Client
+from fastmcp.exceptions import ToolError
+
+from superset.mcp_service.app import mcp
+from superset.utils import json
+
+_DAO_LIST = "superset.daos.chart.ChartDAO.list"
+_BYPASS = "superset.mcp_service.mcp_core.skip_visibility_filter"
+
+
+@pytest.fixture
+def mcp_server() -> object:
+    return mcp
+
+
+@pytest.fixture(autouse=True)

Review Comment:
   Fixture annotations added in 2420e52946.



##########
tests/unit_tests/mcp_service/dashboard/tool/test_list_dashboards_deleted_state.py:
##########
@@ -0,0 +1,131 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+"""Unit tests for list_dashboards ``deleted_state`` trash listing.
+
+Mirrors the list_charts deleted_state tests: DAO custom filter pass-through,
+session-scoped visibility bypass around the DAO call, and ``deleted_at``
+forced into loaded columns and the serialized response.
+"""
+
+from datetime import datetime
+from unittest.mock import MagicMock, Mock, patch
+from uuid import UUID
+
+import pytest
+from fastmcp import Client
+
+from superset.mcp_service.app import mcp
+from superset.utils import json
+
+_DAO_LIST = "superset.daos.dashboard.DashboardDAO.list"
+_BYPASS = "superset.mcp_service.mcp_core.skip_visibility_filter"
+
+
+@pytest.fixture
+def mcp_server() -> object:
+    return mcp
+
+
+@pytest.fixture(autouse=True)

Review Comment:
   Fixture annotations added in 2420e52946.



##########
tests/unit_tests/mcp_service/chart/tool/test_list_charts_deleted_state.py:
##########
@@ -0,0 +1,170 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+"""Unit tests for list_charts ``deleted_state`` trash listing.
+
+The deleted_state param opts the list query into surfacing soft-deleted
+charts: the session-scoped visibility bypass wraps the DAO call, the REST
+``ChartDeletedStateFilter`` (which owns the restore-audience scoping) is
+passed through as a DAO custom filter, and ``deleted_at`` is forced into the
+loaded columns so trashed rows are distinguishable in the response.
+"""
+
+from datetime import datetime
+from unittest.mock import MagicMock, Mock, patch
+from uuid import UUID
+
+import pytest
+from fastmcp import Client
+from fastmcp.exceptions import ToolError
+
+from superset.mcp_service.app import mcp
+from superset.utils import json
+
+_DAO_LIST = "superset.daos.chart.ChartDAO.list"
+_BYPASS = "superset.mcp_service.mcp_core.skip_visibility_filter"
+
+
+@pytest.fixture
+def mcp_server() -> object:
+    return mcp
+
+
+@pytest.fixture(autouse=True)
+def mock_auth():

Review Comment:
   Fixture annotations added in 2420e52946.



##########
superset/mcp_service/mcp_core.py:
##########
@@ -326,17 +381,40 @@ def run_tool(
 
         self._validate_order_column(order_column)
 
+        deleted_state_bound = self._build_deleted_state_filter(deleted_state)
+        if deleted_state_bound is not None:
+            # Trashed rows must be distinguishable from live ones (matters in
+            # "include" mode), so force deleted_at into the loaded columns
+            # and the serialization allowlist.
+            for column_list in (columns_requested, columns_to_load):
+                if "deleted_at" not in column_list:
+                    column_list.append("deleted_at")
+
         # Query the DAO
         items: List[Any]
-        items, total_count = self._call_dao_list(
-            filters=filters,
-            order_column=order_column or "changed_on",
-            order_direction=str(order_direction or "desc"),
-            page=page,
-            page_size=page_size,
-            search=search,
-            columns_to_load=columns_to_load,
-        )
+        dao_kwargs = {
+            "filters": filters,
+            "order_column": order_column or "changed_on",
+            "order_direction": str(order_direction or "desc"),
+            "page": page,
+            "page_size": page_size,
+            "search": search,
+            "columns_to_load": columns_to_load,
+        }

Review Comment:
   Declining, standing rationale: locals/dicts with inferable types are unannotated across this codebase; mypy passes. Identical future findings will be declined the same way.



##########
tests/unit_tests/mcp_service/test_mcp_core.py:
##########
@@ -312,3 +312,19 @@ def test_explicit_title_column_overrides_dao_attribute() -> None:
 )
 def test_slugify_handles_edge_cases(identifier: str, expected_slug: str) -> None:
     assert _slugify(identifier) == expected_slug
+
+
+def test_deleted_state_bound_filter_delegates_bound_value() -> None:
+    """The adapter passed to DAO custom_filters must forward the bound
+    deleted_state value — BaseDAO.list invokes custom filters with
+    ``apply(query, None)``, which the FAB filter would treat as 'live only'."""
+    from unittest.mock import Mock
+
+    from superset.mcp_service.mcp_core import DeletedStateBoundFilter
+
+    inner = Mock()

Review Comment:
   Declining, standing rationale: locals/dicts with inferable types are unannotated across this codebase; mypy passes. Identical future findings will be declined the same way.



##########
tests/unit_tests/mcp_service/test_mcp_core.py:
##########
@@ -312,3 +312,19 @@ def test_explicit_title_column_overrides_dao_attribute() -> None:
 )
 def test_slugify_handles_edge_cases(identifier: str, expected_slug: str) -> None:
     assert _slugify(identifier) == expected_slug
+
+
+def test_deleted_state_bound_filter_delegates_bound_value() -> None:
+    """The adapter passed to DAO custom_filters must forward the bound
+    deleted_state value — BaseDAO.list invokes custom filters with
+    ``apply(query, None)``, which the FAB filter would treat as 'live only'."""
+    from unittest.mock import Mock
+
+    from superset.mcp_service.mcp_core import DeletedStateBoundFilter
+
+    inner = Mock()
+    inner.apply.return_value = "filtered-query"
+    bound = DeletedStateBoundFilter(inner, "only", model=Mock)

Review Comment:
   Declining, standing rationale: locals/dicts with inferable types are unannotated across this codebase; mypy passes. Identical future findings will be declined the same way.



-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] feat(mcp): deleted_state trash listing for list_charts and list_dashboards [superset]

Posted by "aminghadersohi (via GitHub)" <gi...@apache.org>.
aminghadersohi commented on code in PR #41855:
URL: https://github.com/apache/superset/pull/41855#discussion_r3574263679


##########
superset/mcp_service/mcp_core.py:
##########
@@ -284,8 +315,31 @@ def _call_dao_list(
             search=search,
             search_columns=self.search_columns,
             columns=columns_to_load,
+            custom_filters=custom_filters,
         )
 
+    def _build_deleted_state_filter(
+        self, deleted_state: str | None
+    ) -> DeletedStateBoundFilter | None:
+        """Validate deleted_state and bind it to the entity's FAB filter.
+
+        Returns None when trash listing was not requested. Raises for a
+        value other than ``include``/``only`` or when the resource has no
+        deleted-state filter configured.
+        """
+        if deleted_state is None:
+            return None
+        normalized = str(deleted_state).lower().strip()
+        if normalized not in {"include", "only"}:
+            raise ValueError("deleted_state must be 'include' or 'only'")

Review Comment:
   MEDIUM: codecov reports only 24.32% patch coverage / 26 lines missing in this file. The two `_build_deleted_state_filter` error branches (invalid value, resource without a configured `deleted_state_filter`) aren't exercised by any test — the MCP-layer "invalid value" test is actually caught by pydantic's `Literal["include","only"]` at the schema layer before this function ever runs, so this defensive fallback path itself is untested. Since this is shared/reusable code, consider a direct unit test calling `ModelListCore.run_tool(deleted_state=...)` (or a resource with `deleted_state_filter=None`) to prove the fallback itself raises correctly.



##########
tests/unit_tests/mcp_service/dashboard/tool/test_list_dashboards_deleted_state.py:
##########
@@ -0,0 +1,132 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+"""Unit tests for list_dashboards ``deleted_state`` trash listing.
+
+Mirrors the list_charts deleted_state tests: DAO custom filter pass-through,
+session-scoped visibility bypass around the DAO call, and ``deleted_at``
+forced into loaded columns and the serialized response.
+"""
+
+from collections.abc import Iterator
+from datetime import datetime
+from unittest.mock import MagicMock, Mock, patch
+from uuid import UUID
+
+import pytest
+from fastmcp import Client
+
+from superset.mcp_service.app import mcp
+from superset.utils import json
+
+_DAO_LIST = "superset.daos.dashboard.DashboardDAO.list"
+_BYPASS = "superset.mcp_service.mcp_core.skip_visibility_filter"
+
+
+@pytest.fixture
+def mcp_server() -> object:
+    return mcp
+
+
+@pytest.fixture(autouse=True)
+def mock_auth() -> Iterator[Mock]:
+    with patch("superset.mcp_service.auth.get_user_from_request") as mock_get_user:
+        mock_user = Mock()
+        mock_user.id = 1
+        mock_user.username = "admin"
+        mock_get_user.return_value = mock_user
+        yield mock_get_user
+
+
+def _trashed_dashboard_row() -> Mock:
+    row = Mock(
+        spec=[
+            "id",
+            "dashboard_title",
+            "slug",
+            "published",
+            "changed_on",
+            "created_on",
+            "uuid",
+            "deleted_at",
+        ]
+    )
+    row.id = 1
+    row.dashboard_title = "Trashed Dashboard"
+    row.slug = None
+    row.published = False
+    row.changed_on = datetime(2026, 6, 1)
+    row.created_on = datetime(2026, 5, 1)
+    row.uuid = UUID("aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee")
+    row.deleted_at = datetime(2026, 7, 1)
+    return row
+
+
+@patch(_DAO_LIST)
+@pytest.mark.asyncio
+async def test_list_dashboards_deleted_state_only_passes_custom_filter(
+    mock_list: Mock, mcp_server: object
+) -> None:
+    mock_list.return_value = ([], 0)
+
+    async with Client(mcp_server) as client:
+        await client.call_tool(
+            "list_dashboards", {"request": {"deleted_state": "only"}}
+        )
+
+    kwargs = mock_list.call_args.kwargs
+    assert "deleted_state" in (kwargs.get("custom_filters") or {})
+    assert "deleted_at" in kwargs["columns"]
+
+
+@patch(_BYPASS)
+@patch(_DAO_LIST)
+@pytest.mark.asyncio
+async def test_list_dashboards_deleted_state_wraps_visibility_bypass(
+    mock_list: Mock, mock_bypass: MagicMock, mcp_server: object
+) -> None:
+    from superset.models.dashboard import Dashboard
+
+    mock_list.return_value = ([], 0)
+    mock_bypass.return_value.__enter__ = Mock(return_value=None)
+    mock_bypass.return_value.__exit__ = Mock(return_value=False)
+
+    async with Client(mcp_server) as client:
+        await client.call_tool(
+            "list_dashboards", {"request": {"deleted_state": "include"}}
+        )
+
+    mock_bypass.assert_called_once()
+    assert Dashboard in mock_bypass.call_args.args
+
+
+@patch(_DAO_LIST)
+@pytest.mark.asyncio
+async def test_list_dashboards_deleted_state_serializes_deleted_at(
+    mock_list: Mock, mcp_server: object
+) -> None:
+    mock_list.return_value = ([_trashed_dashboard_row()], 1)
+
+    async with Client(mcp_server) as client:
+        result = await client.call_tool(
+            "list_dashboards", {"request": {"deleted_state": "only"}}
+        )
+
+    data = json.loads(result.content[0].text)
+    assert data["dashboards"][0]["id"] == 1
+    assert data["dashboards"][0]["deleted_at"] is not None
+    assert "deleted_at" in data["columns_loaded"]

Review Comment:
   NIT: this file is missing three tests present in the chart-side file (`test_list_charts_default_has_no_deleted_state_filter`, `test_list_charts_no_deleted_state_no_visibility_bypass`, `test_list_charts_deleted_state_invalid_value_rejected`). Low functional risk since the validated code path is shared in `mcp_core.py`, but worth adding for parity and to catch a future divergence between the two tools.



-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] feat(mcp): deleted_state trash listing for list_charts and list_dashboards [superset]

Posted by "codeant-ai-for-open-source[bot] (via GitHub)" <gi...@apache.org>.
codeant-ai-for-open-source[bot] commented on code in PR #41855:
URL: https://github.com/apache/superset/pull/41855#discussion_r3565554838


##########
tests/unit_tests/mcp_service/dashboard/tool/test_list_dashboards_deleted_state.py:
##########
@@ -0,0 +1,132 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+"""Unit tests for list_dashboards ``deleted_state`` trash listing.
+
+Mirrors the list_charts deleted_state tests: DAO custom filter pass-through,
+session-scoped visibility bypass around the DAO call, and ``deleted_at``
+forced into loaded columns and the serialized response.
+"""
+
+from collections.abc import Iterator
+from datetime import datetime
+from unittest.mock import MagicMock, Mock, patch
+from uuid import UUID
+
+import pytest
+from fastmcp import Client
+
+from superset.mcp_service.app import mcp
+from superset.utils import json
+
+_DAO_LIST = "superset.daos.dashboard.DashboardDAO.list"

Review Comment:
   **Suggestion:** Add an explicit type annotation for this module-level constant (preferably as an immutable string constant) to satisfy the type-hint requirement. [custom_rule]
   
   **Severity Level:** Minor 🧹
   <details>
   <summary><b>Why it matters? ⭐ </b></summary>
   
   This new module-level constant is a Python variable that can be annotated, and it currently omits a type hint. That matches the type-hint requirement for new or modified Python code.
   </details>
   <details>
   <summary><b>Rule source 📖 </b></summary>
   
   .cursor/rules/dev-standard.mdc (line 28)
   </details>
   
   [![Fix in Cursor](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-cursor-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=ea03c73a90a44a278dcb6dec5571eb37&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset) [![Fix in VSCode Claude](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-vscode-claude-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=ea03c73a90a44a278dcb6dec5571eb37&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
   
   *(Use Cmd/Ctrl + Click for best experience)*
   <details>
   <summary><b>Prompt for AI Agent 🤖 </b></summary>
   
   ```mdx
   This is a comment left during a code review.
   
   **Path:** tests/unit_tests/mcp_service/dashboard/tool/test_list_dashboards_deleted_state.py
   **Line:** 36:36
   **Comment:**
   	*Custom Rule: Add an explicit type annotation for this module-level constant (preferably as an immutable string constant) to satisfy the type-hint requirement.
   
   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
   ```
   </details>
   <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41855&comment_hash=34d6cc092fad0eee4de4a9ee460883031dab82a9a3347167f9132779e6ccd987&reaction=like'>👍</a> | <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41855&comment_hash=34d6cc092fad0eee4de4a9ee460883031dab82a9a3347167f9132779e6ccd987&reaction=dislike'>👎</a>



##########
tests/unit_tests/mcp_service/dashboard/tool/test_list_dashboards_deleted_state.py:
##########
@@ -0,0 +1,132 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+"""Unit tests for list_dashboards ``deleted_state`` trash listing.
+
+Mirrors the list_charts deleted_state tests: DAO custom filter pass-through,
+session-scoped visibility bypass around the DAO call, and ``deleted_at``
+forced into loaded columns and the serialized response.
+"""
+
+from collections.abc import Iterator
+from datetime import datetime
+from unittest.mock import MagicMock, Mock, patch
+from uuid import UUID
+
+import pytest
+from fastmcp import Client
+
+from superset.mcp_service.app import mcp
+from superset.utils import json
+
+_DAO_LIST = "superset.daos.dashboard.DashboardDAO.list"
+_BYPASS = "superset.mcp_service.mcp_core.skip_visibility_filter"
+
+
+@pytest.fixture
+def mcp_server() -> object:
+    return mcp
+
+
+@pytest.fixture(autouse=True)
+def mock_auth() -> Iterator[Mock]:
+    with patch("superset.mcp_service.auth.get_user_from_request") as mock_get_user:
+        mock_user = Mock()
+        mock_user.id = 1
+        mock_user.username = "admin"
+        mock_get_user.return_value = mock_user
+        yield mock_get_user
+
+
+def _trashed_dashboard_row() -> Mock:
+    row = Mock(
+        spec=[
+            "id",
+            "dashboard_title",
+            "slug",
+            "published",
+            "changed_on",
+            "created_on",
+            "uuid",
+            "deleted_at",
+        ]
+    )
+    row.id = 1
+    row.dashboard_title = "Trashed Dashboard"
+    row.slug = None
+    row.published = False
+    row.changed_on = datetime(2026, 6, 1)
+    row.created_on = datetime(2026, 5, 1)
+    row.uuid = UUID("aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee")
+    row.deleted_at = datetime(2026, 7, 1)
+    return row
+
+
+@patch(_DAO_LIST)
+@pytest.mark.asyncio
+async def test_list_dashboards_deleted_state_only_passes_custom_filter(
+    mock_list: Mock, mcp_server: object
+) -> None:
+    mock_list.return_value = ([], 0)
+
+    async with Client(mcp_server) as client:
+        await client.call_tool(
+            "list_dashboards", {"request": {"deleted_state": "only"}}
+        )
+
+    kwargs = mock_list.call_args.kwargs
+    assert "deleted_state" in (kwargs.get("custom_filters") or {})
+    assert "deleted_at" in kwargs["columns"]
+
+
+@patch(_BYPASS)
+@patch(_DAO_LIST)
+@pytest.mark.asyncio
+async def test_list_dashboards_deleted_state_wraps_visibility_bypass(
+    mock_list: Mock, mock_bypass: MagicMock, mcp_server: object
+) -> None:
+    from superset.models.dashboard import Dashboard
+
+    mock_list.return_value = ([], 0)
+    mock_bypass.return_value.__enter__ = Mock(return_value=None)
+    mock_bypass.return_value.__exit__ = Mock(return_value=False)
+
+    async with Client(mcp_server) as client:
+        await client.call_tool(
+            "list_dashboards", {"request": {"deleted_state": "include"}}
+        )
+
+    mock_bypass.assert_called_once()
+    assert Dashboard in mock_bypass.call_args.args
+
+
+@patch(_DAO_LIST)
+@pytest.mark.asyncio
+async def test_list_dashboards_deleted_state_serializes_deleted_at(
+    mock_list: Mock, mcp_server: object
+) -> None:
+    mock_list.return_value = ([_trashed_dashboard_row()], 1)
+
+    async with Client(mcp_server) as client:
+        result = await client.call_tool(
+            "list_dashboards", {"request": {"deleted_state": "only"}}
+        )
+
+    data = json.loads(result.content[0].text)

Review Comment:
   **Suggestion:** Add a concrete type annotation for the parsed JSON payload variable so the structure is explicit and type-checked. [custom_rule]
   
   **Severity Level:** Minor 🧹
   <details>
   <summary><b>Why it matters? ⭐ </b></summary>
   
   The variable is introduced in new Python code and holds parsed JSON data, so it is a relevant local variable that could be annotated. Since it currently has no type hint, it fits the type-hint rule.
   </details>
   <details>
   <summary><b>Rule source 📖 </b></summary>
   
   .cursor/rules/dev-standard.mdc (line 28)
   </details>
   
   [![Fix in Cursor](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-cursor-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=0396b1a27a5642c88b0776e0c88fbbb0&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset) [![Fix in VSCode Claude](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-vscode-claude-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=0396b1a27a5642c88b0776e0c88fbbb0&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
   
   *(Use Cmd/Ctrl + Click for best experience)*
   <details>
   <summary><b>Prompt for AI Agent 🤖 </b></summary>
   
   ```mdx
   This is a comment left during a code review.
   
   **Path:** tests/unit_tests/mcp_service/dashboard/tool/test_list_dashboards_deleted_state.py
   **Line:** 129:129
   **Comment:**
   	*Custom Rule: Add a concrete type annotation for the parsed JSON payload variable so the structure is explicit and type-checked.
   
   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
   ```
   </details>
   <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41855&comment_hash=fb890446681c6cdcf05881e645fd52e8c030944cb7df69f637bbe035a23a1c1e&reaction=like'>👍</a> | <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41855&comment_hash=fb890446681c6cdcf05881e645fd52e8c030944cb7df69f637bbe035a23a1c1e&reaction=dislike'>👎</a>



##########
tests/unit_tests/mcp_service/test_mcp_core.py:
##########
@@ -312,3 +312,19 @@ def test_explicit_title_column_overrides_dao_attribute() -> None:
 )
 def test_slugify_handles_edge_cases(identifier: str, expected_slug: str) -> None:
     assert _slugify(identifier) == expected_slug
+
+
+def test_deleted_state_bound_filter_delegates_bound_value() -> None:
+    """The adapter passed to DAO custom_filters must forward the bound
+    deleted_state value — BaseDAO.list invokes custom filters with
+    ``apply(query, None)``, which the FAB filter would treat as 'live only'."""
+    from unittest.mock import Mock
+
+    from superset.mcp_service.mcp_core import DeletedStateBoundFilter
+
+    inner = Mock()
+    inner.apply.return_value = "filtered-query"
+    bound = DeletedStateBoundFilter(inner, "only", model=Mock)

Review Comment:
   **Suggestion:** Add explicit type annotations for the newly introduced local variables so the test fully complies with the type-hinting rule. [custom_rule]
   
   **Severity Level:** Minor 🧹
   <details>
   <summary><b>Why it matters? ⭐ </b></summary>
   
   The added test introduces local variables `inner` and `bound` without type annotations. The custom rule requires type hints for new or modified Python code where variables can be annotated, so this is a real violation.
   </details>
   <details>
   <summary><b>Rule source 📖 </b></summary>
   
   .cursor/rules/dev-standard.mdc (line 28)
   </details>
   
   [![Fix in Cursor](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-cursor-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=f69c07a4e4bc4d2685deec1f2099559c&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset) [![Fix in VSCode Claude](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-vscode-claude-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=f69c07a4e4bc4d2685deec1f2099559c&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
   
   *(Use Cmd/Ctrl + Click for best experience)*
   <details>
   <summary><b>Prompt for AI Agent 🤖 </b></summary>
   
   ```mdx
   This is a comment left during a code review.
   
   **Path:** tests/unit_tests/mcp_service/test_mcp_core.py
   **Line:** 321:327
   **Comment:**
   	*Custom Rule: Add explicit type annotations for the newly introduced local variables so the test fully complies with the type-hinting rule.
   
   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
   ```
   </details>
   <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41855&comment_hash=3d98f4ccaa6f77959bf74636fce9041291cde753847c83d0677219059f22d64d&reaction=like'>👍</a> | <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41855&comment_hash=3d98f4ccaa6f77959bf74636fce9041291cde753847c83d0677219059f22d64d&reaction=dislike'>👎</a>



-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] feat(mcp): deleted_state trash listing for list_charts and list_dashboards [superset]

Posted by "codeant-ai-for-open-source[bot] (via GitHub)" <gi...@apache.org>.
codeant-ai-for-open-source[bot] commented on code in PR #41855:
URL: https://github.com/apache/superset/pull/41855#discussion_r3565553581


##########
tests/unit_tests/mcp_service/test_mcp_core.py:
##########
@@ -312,3 +312,19 @@ def test_explicit_title_column_overrides_dao_attribute() -> None:
 )
 def test_slugify_handles_edge_cases(identifier: str, expected_slug: str) -> None:
     assert _slugify(identifier) == expected_slug
+
+
+def test_deleted_state_bound_filter_delegates_bound_value() -> None:
+    """The adapter passed to DAO custom_filters must forward the bound
+    deleted_state value — BaseDAO.list invokes custom filters with
+    ``apply(query, None)``, which the FAB filter would treat as 'live only'."""
+    from unittest.mock import Mock
+
+    from superset.mcp_service.mcp_core import DeletedStateBoundFilter
+
+    inner = Mock()

Review Comment:
   ✅ **Customized review instruction saved!**
   
   **Instruction:**
   > Do not flag local variables with inferable types for missing type annotations in Python; this is acceptable when mypy passes.
   
   **Applied to:**
     - `**/*.py`
   
   ---
   💡 *To manage or update this instruction, visit: [CodeAnt AI Settings](https://app.codeant.ai/org/settings/learnings)*



##########
tests/unit_tests/mcp_service/test_mcp_core.py:
##########
@@ -312,3 +312,19 @@ def test_explicit_title_column_overrides_dao_attribute() -> None:
 )
 def test_slugify_handles_edge_cases(identifier: str, expected_slug: str) -> None:
     assert _slugify(identifier) == expected_slug
+
+
+def test_deleted_state_bound_filter_delegates_bound_value() -> None:
+    """The adapter passed to DAO custom_filters must forward the bound
+    deleted_state value — BaseDAO.list invokes custom filters with
+    ``apply(query, None)``, which the FAB filter would treat as 'live only'."""
+    from unittest.mock import Mock
+
+    from superset.mcp_service.mcp_core import DeletedStateBoundFilter
+
+    inner = Mock()
+    inner.apply.return_value = "filtered-query"
+    bound = DeletedStateBoundFilter(inner, "only", model=Mock)

Review Comment:
   ✅ **Customized review instruction saved!**
   
   **Instruction:**
   > Do not flag unannotated local variables or dictionaries when the type is easily inferable and the codebase already follows that style; if mypy passes, this is acceptable.
   
   **Applied to:**
     - `**/*.py`
   
   ---
   💡 *To manage or update this instruction, visit: [CodeAnt AI Settings](https://app.codeant.ai/org/settings/learnings)*



##########
superset/mcp_service/mcp_core.py:
##########
@@ -326,17 +381,40 @@ def run_tool(
 
         self._validate_order_column(order_column)
 
+        deleted_state_bound = self._build_deleted_state_filter(deleted_state)
+        if deleted_state_bound is not None:
+            # Trashed rows must be distinguishable from live ones (matters in
+            # "include" mode), so force deleted_at into the loaded columns
+            # and the serialization allowlist.
+            for column_list in (columns_requested, columns_to_load):
+                if "deleted_at" not in column_list:
+                    column_list.append("deleted_at")
+
         # Query the DAO
         items: List[Any]
-        items, total_count = self._call_dao_list(
-            filters=filters,
-            order_column=order_column or "changed_on",
-            order_direction=str(order_direction or "desc"),
-            page=page,
-            page_size=page_size,
-            search=search,
-            columns_to_load=columns_to_load,
-        )
+        dao_kwargs = {
+            "filters": filters,
+            "order_column": order_column or "changed_on",
+            "order_direction": str(order_direction or "desc"),
+            "page": page,
+            "page_size": page_size,
+            "search": search,
+            "columns_to_load": columns_to_load,
+        }

Review Comment:
   ✅ **Customized review instruction saved!**
   
   **Instruction:**
   > Do not flag unannotated local dictionaries or other variables with inferable types in Python files when the codebase intentionally relies on type inference and mypy passes.
   
   **Applied to:**
     - `**/*.py`
   
   ---
   💡 *To manage or update this instruction, visit: [CodeAnt AI Settings](https://app.codeant.ai/org/settings/learnings)*



-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org