codeant-ai-for-open-source[bot] commented on code in PR #41753:
URL: https://github.com/apache/superset/pull/41753#discussion_r3531296821


##########
superset/charts/filters.py:
##########
@@ -106,6 +109,10 @@ def apply(self, query: Query, value: Any) -> Query:
         if security_manager.can_access_all_datasources():
             return query
 
+        # Embedded guests: scope to charts on the dashboards in their token.
+        if (guest_dashboards := guest_embedded_dashboard_filter()) is not None:

Review Comment:
   **Suggestion:** Replace the inline walrus assignment with a separately 
declared local variable and add an explicit type annotation before the 
conditional check. [custom_rule]
   
   **Severity Level:** Minor ⚠️
   <details>
   <summary><b>Why it matters? 🤔 </b></summary>
   
   The new walrus-assigned local variable `guest_dashboards` is introduced 
without any type hint. This matches the rule about flagging modified Python 
code that omits type hints on relevant variables that can be annotated, so the 
suggestion identifies a real violation.
   </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=1fb018e5c1d14e669e8ee483f2206a0b&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=1fb018e5c1d14e669e8ee483f2206a0b&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/charts/filters.py
   **Line:** 113:113
   **Comment:**
        *Custom Rule: Replace the inline walrus assignment with a separately 
declared local variable and add an explicit type annotation before the 
conditional check.
   
   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%2F41753&comment_hash=14ee394ff198807c8acc810e0be88daff3b3dc9ffed9f1fe75c0af332cee2476&reaction=like'>👍</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41753&comment_hash=14ee394ff198807c8acc810e0be88daff3b3dc9ffed9f1fe75c0af332cee2476&reaction=dislike'>👎</a>



##########
superset/mcp_service/guest_scope.py:
##########
@@ -0,0 +1,72 @@
+# 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.
+
+"""Embedded-guest data-query authorization for MCP chart tools.
+
+Chart *resolution* is scoped for guests by the core ``ChartFilter`` (mirroring
+``DashboardAccessFilter``). This module handles the remaining MCP-layer 
concern:
+attaching the embedded dashboard context to a chart's data query so the 
existing
+guest ``raise_for_access`` branch authorizes it, exactly as the embedded
+dashboard frontend does.
+"""
+
+from __future__ import annotations
+
+import logging
+from typing import Any
+
+logger = logging.getLogger(__name__)

Review Comment:
   **Suggestion:** Add an explicit type annotation to this module-level 
variable (for example, as a logger type) to comply with the type-hint 
requirement for relevant variables. [custom_rule]
   
   **Severity Level:** Minor ⚠️
   <details>
   <summary><b>Why it matters? 🤔 </b></summary>
   
   The module introduces a new module-level variable without a type annotation. 
This matches the custom rule requiring type hints for relevant variables that 
can be annotated, so the suggestion is a real violation.
   </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=d76bdb9ec9964f908682c1601c4aa46a&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=d76bdb9ec9964f908682c1601c4aa46a&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/guest_scope.py
   **Line:** 32:32
   **Comment:**
        *Custom Rule: Add an explicit type annotation to this module-level 
variable (for example, as a logger type) to comply with the type-hint 
requirement for relevant variables.
   
   Validate the correctness of the flagged issue. If correct, How can I resolve 
this? If you propose a fix, implement it and please make it concise.
   Once fix is implemented, also check other comments on the same PR, and ask 
user if the user wants to fix the rest of the comments as well. if said yes, 
then fetch all the comments validate the correctness and implement a minimal fix
   ```
   </details>
   <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41753&comment_hash=83f87dd5ebcc9e939b5782e09c50fac98125814479f9a4ea200aecf6624e11dd&reaction=like'>👍</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41753&comment_hash=83f87dd5ebcc9e939b5782e09c50fac98125814479f9a4ea200aecf6624e11dd&reaction=dislike'>👎</a>



##########
superset/mcp_service/chart/tool/get_chart_data.py:
##########
@@ -395,21 +411,23 @@ async def get_chart_data(  # noqa: C901
         )
         logger.info("Getting data for chart %s: %s", chart.id, 
chart.slice_name)
 
-        # Validate the chart's dataset is accessible before retrieving data
-        validation_result = validate_chart_dataset(chart, check_access=True)
-        if not validation_result.is_valid:
-            await ctx.warning(
-                "Chart found but dataset is not accessible: %s"
-                % (validation_result.error,)
-            )
-            return ChartError(
-                error=validation_result.error
-                or "Chart's dataset is not accessible. Dataset may have been 
deleted.",
-                error_type="DatasetNotAccessible",
-            )
-        # Log any warnings (e.g., virtual dataset warnings)
-        for warning in validation_result.warnings:
-            await ctx.warning("Dataset warning: %s" % (warning,))
+        # Skip the dataset RBAC pre-check for guests (see 
guest_scope.is_guest_read).
+        if not guest_scope.is_guest_read():
+            validation_result = validate_chart_dataset(chart, 
check_access=True)

Review Comment:
   **Suggestion:** Add an explicit type annotation for this newly introduced 
intermediate variable to satisfy the type-hinting requirement for relevant 
variables. [custom_rule]
   
   **Severity Level:** Minor ⚠️
   <details>
   <summary><b>Why it matters? 🤔 </b></summary>
   
   This new local variable is introduced without a type hint, and it is a 
relevant annotatable variable in modified Python code, so it matches the 
type-hinting rule violation.
   </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=d014c3ff86df40b2863fb46e1bd6e45f&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=d014c3ff86df40b2863fb46e1bd6e45f&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/chart/tool/get_chart_data.py
   **Line:** 416:416
   **Comment:**
        *Custom Rule: Add an explicit type annotation for this newly introduced 
intermediate variable to satisfy the type-hinting requirement for relevant 
variables.
   
   Validate the correctness of the flagged issue. If correct, How can I resolve 
this? If you propose a fix, implement it and please make it concise.
   Once fix is implemented, also check other comments on the same PR, and ask 
user if the user wants to fix the rest of the comments as well. if said yes, 
then fetch all the comments validate the correctness and implement a minimal fix
   ```
   </details>
   <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41753&comment_hash=dac60761748b768fada36ff5b9a7b138c18bb38c80aa728626f3b14eae92061c&reaction=like'>👍</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41753&comment_hash=dac60761748b768fada36ff5b9a7b138c18bb38c80aa728626f3b14eae92061c&reaction=dislike'>👎</a>



##########
tests/unit_tests/charts/test_filters.py:
##########
@@ -0,0 +1,119 @@
+# 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.
+
+"""Tests for the ``ChartFilter`` embedded-guest scoping branch."""
+
+from typing import Any
+from unittest.mock import MagicMock
+
+import pytest
+from pytest_mock import MockerFixture
+from sqlalchemy import create_engine
+
+
+def test_chart_filter_scopes_guest_to_token_dashboards(mocker: MockerFixture) 
-> None:
+    """A guest's chart list is scoped to the dashboards in its token."""
+    from superset.charts.filters import ChartFilter
+    from superset.extensions import security_manager
+    from superset.models.dashboard import Dashboard
+    from superset.models.slice import Slice
+
+    mocker.patch.object(
+        security_manager, "can_access_all_datasources", return_value=False
+    )
+    mocker.patch(
+        "superset.charts.filters.guest_embedded_dashboard_filter",
+        return_value=Dashboard.id.in_([1, 2]),
+    )
+
+    captured: dict[str, Any] = {}
+    query = MagicMock()

Review Comment:
   **Suggestion:** Add an explicit type annotation for this mock query variable 
to satisfy the type-hint requirement for relevant local variables. [custom_rule]
   
   **Severity Level:** Minor ⚠️
   <details>
   <summary><b>Why it matters? 🤔 </b></summary>
   
   The new Python test code introduces a local variable without a type hint. 
Since the rule requires type hints on relevant variables that can be annotated, 
this unannotated mock query variable is a real violation.
   </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=f939cd8a7db343f19d1af94bd854a5e7&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=f939cd8a7db343f19d1af94bd854a5e7&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/charts/test_filters.py
   **Line:** 44:44
   **Comment:**
        *Custom Rule: Add an explicit type annotation for this mock query 
variable 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%2F41753&comment_hash=70457def0435cb0ec424deec594848a0adc9032761603a2f95b31b4ae8791cfd&reaction=like'>👍</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41753&comment_hash=70457def0435cb0ec424deec594848a0adc9032761603a2f95b31b4ae8791cfd&reaction=dislike'>👎</a>



##########
tests/unit_tests/charts/test_filters.py:
##########
@@ -0,0 +1,119 @@
+# 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.
+
+"""Tests for the ``ChartFilter`` embedded-guest scoping branch."""
+
+from typing import Any
+from unittest.mock import MagicMock
+
+import pytest
+from pytest_mock import MockerFixture
+from sqlalchemy import create_engine
+
+
+def test_chart_filter_scopes_guest_to_token_dashboards(mocker: MockerFixture) 
-> None:
+    """A guest's chart list is scoped to the dashboards in its token."""
+    from superset.charts.filters import ChartFilter
+    from superset.extensions import security_manager
+    from superset.models.dashboard import Dashboard
+    from superset.models.slice import Slice
+
+    mocker.patch.object(
+        security_manager, "can_access_all_datasources", return_value=False
+    )
+    mocker.patch(
+        "superset.charts.filters.guest_embedded_dashboard_filter",
+        return_value=Dashboard.id.in_([1, 2]),
+    )
+
+    captured: dict[str, Any] = {}
+    query = MagicMock()
+
+    def _capture_filter(clause: object) -> MagicMock:
+        captured["clause"] = clause
+        return query
+
+    query.filter.side_effect = _capture_filter
+
+    filt = ChartFilter.__new__(ChartFilter)
+    filt.model = Slice
+    result = filt.apply(query, None)
+
+    assert result is query
+    query.filter.assert_called_once()
+    # Guest branch returns early: it must NOT take the datasource-access join 
path.
+    query.join.assert_not_called()
+
+    compiled = str(
+        captured["clause"].compile(
+            create_engine("sqlite://"), compile_kwargs={"literal_binds": True}
+        )
+    )
+    assert "EXISTS" in compiled  # scoped via the m2m dashboards relationship
+    assert "IN (1, 2)" in compiled
+
+
+def test_chart_filter_non_guest_skips_guest_branch(mocker: MockerFixture) -> 
None:
+    """With no embedded guest, ChartFilter does not take the guest branch (it
+    proceeds to the datasource-access join instead of filtering on 
dashboards)."""
+    from superset.charts.filters import ChartFilter
+    from superset.extensions import security_manager
+    from superset.models.slice import Slice
+
+    mocker.patch.object(
+        security_manager, "can_access_all_datasources", return_value=False
+    )
+    guest_filter = mocker.patch(
+        "superset.charts.filters.guest_embedded_dashboard_filter", 
return_value=None
+    )
+    # Stop apply right after the guest check so we don't exercise the (heavily
+    # env-dependent) datasource-access path — reaching the join proves the 
guest
+    # branch was skipped.
+    sentinel = RuntimeError("reached datasource-access join")
+    query = MagicMock()

Review Comment:
   **Suggestion:** Add an explicit type annotation for this query mock variable 
in this test as well to keep type hints consistent across relevant locals. 
[custom_rule]
   
   **Severity Level:** Minor ⚠️
   <details>
   <summary><b>Why it matters? 🤔 </b></summary>
   
   This is another newly added local variable in Python code without a type 
hint. Because the rule applies to relevant variables that can be annotated, 
this is a verified violation as well.
   </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=dc465628881b4cb0b6ac108e644a70db&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=dc465628881b4cb0b6ac108e644a70db&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/charts/test_filters.py
   **Line:** 87:87
   **Comment:**
        *Custom Rule: Add an explicit type annotation for this query mock 
variable in this test as well to keep type hints consistent across relevant 
locals.
   
   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%2F41753&comment_hash=32b68ccf301c58782f6c8897deb90971508cb27b554a1c1c79bf22d56f797f94&reaction=like'>👍</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41753&comment_hash=32b68ccf301c58782f6c8897deb90971508cb27b554a1c1c79bf22d56f797f94&reaction=dislike'>👎</a>



##########
tests/unit_tests/charts/test_filters.py:
##########
@@ -0,0 +1,119 @@
+# 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.
+
+"""Tests for the ``ChartFilter`` embedded-guest scoping branch."""
+
+from typing import Any
+from unittest.mock import MagicMock
+
+import pytest
+from pytest_mock import MockerFixture
+from sqlalchemy import create_engine
+
+
+def test_chart_filter_scopes_guest_to_token_dashboards(mocker: MockerFixture) 
-> None:
+    """A guest's chart list is scoped to the dashboards in its token."""
+    from superset.charts.filters import ChartFilter
+    from superset.extensions import security_manager
+    from superset.models.dashboard import Dashboard
+    from superset.models.slice import Slice
+
+    mocker.patch.object(
+        security_manager, "can_access_all_datasources", return_value=False
+    )
+    mocker.patch(
+        "superset.charts.filters.guest_embedded_dashboard_filter",
+        return_value=Dashboard.id.in_([1, 2]),
+    )
+
+    captured: dict[str, Any] = {}
+    query = MagicMock()
+
+    def _capture_filter(clause: object) -> MagicMock:
+        captured["clause"] = clause
+        return query
+
+    query.filter.side_effect = _capture_filter
+
+    filt = ChartFilter.__new__(ChartFilter)
+    filt.model = Slice
+    result = filt.apply(query, None)
+
+    assert result is query
+    query.filter.assert_called_once()
+    # Guest branch returns early: it must NOT take the datasource-access join 
path.
+    query.join.assert_not_called()
+
+    compiled = str(
+        captured["clause"].compile(
+            create_engine("sqlite://"), compile_kwargs={"literal_binds": True}
+        )
+    )
+    assert "EXISTS" in compiled  # scoped via the m2m dashboards relationship
+    assert "IN (1, 2)" in compiled
+
+
+def test_chart_filter_non_guest_skips_guest_branch(mocker: MockerFixture) -> 
None:
+    """With no embedded guest, ChartFilter does not take the guest branch (it
+    proceeds to the datasource-access join instead of filtering on 
dashboards)."""
+    from superset.charts.filters import ChartFilter
+    from superset.extensions import security_manager
+    from superset.models.slice import Slice
+
+    mocker.patch.object(
+        security_manager, "can_access_all_datasources", return_value=False
+    )
+    guest_filter = mocker.patch(
+        "superset.charts.filters.guest_embedded_dashboard_filter", 
return_value=None
+    )

Review Comment:
   **Suggestion:** Add a type annotation for this patched object variable so 
the new code does not omit a type hint on a relevant local variable. 
[custom_rule]
   
   **Severity Level:** Minor ⚠️
   <details>
   <summary><b>Why it matters? 🤔 </b></summary>
   
   This patched object is a new local variable in Python code and has no type 
annotation. Under the type-hint rule, a relevant local variable that can be 
annotated should not be left untyped, so the suggestion identifies a real issue.
   </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=39be96f7e9be49f99849924f5ab270b5&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=39be96f7e9be49f99849924f5ab270b5&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/charts/test_filters.py
   **Line:** 80:82
   **Comment:**
        *Custom Rule: Add a type annotation for this patched object variable so 
the new code does not omit a type hint on a relevant local variable.
   
   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%2F41753&comment_hash=2c4407a69cc9ca0527a367bda07476f8e2515907dcef7d5beb9ffca28fbfb4fd&reaction=like'>👍</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41753&comment_hash=2c4407a69cc9ca0527a367bda07476f8e2515907dcef7d5beb9ffca28fbfb4fd&reaction=dislike'>👎</a>



##########
superset/utils/filters.py:
##########
@@ -41,3 +41,35 @@ def get_dataset_access_filters(
         base_model.schema_perm.in_(schema_perms),
         *args,
     )
+
+
+def guest_embedded_dashboard_filter() -> Optional[Any]:
+    """SQLAlchemy condition matching dashboards embedded via the current guest
+    token's resources, or None when the user is not an embedded guest.
+
+    Used by the chart access filter to scope an embedded guest to its token's
+    dashboards (and their charts), mirroring how DashboardAccessFilter already
+    scopes dashboards.
+    """
+    # pylint: disable=import-outside-toplevel
+    from superset import is_feature_enabled, security_manager
+    from superset.models.dashboard import Dashboard, is_uuid
+    from superset.models.embedded_dashboard import EmbeddedDashboard
+    from superset.security.guest_token import GuestTokenResourceType
+
+    if not is_feature_enabled("EMBEDDED_SUPERSET"):
+        return None
+    guest = security_manager.get_current_guest_user_if_guest()
+    if guest is None:
+        return None
+    ids = [
+        r["id"]
+        for r in guest.resources
+        if r["type"] == GuestTokenResourceType.DASHBOARD.value
+    ]

Review Comment:
   **Suggestion:** Add an explicit type annotation for the `ids` local variable 
in this new function so the variable typing is not implicit. [custom_rule]
   
   **Severity Level:** Minor ⚠️
   <details>
   <summary><b>Why it matters? 🤔 </b></summary>
   
   The new function introduces a local variable `ids` whose type is clear from 
context, but it is left unannotated. This matches the custom rule requiring 
type hints on relevant variables that can be annotated.
   </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=c5c54938c59c40ac842e980abc7c8d38&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=c5c54938c59c40ac842e980abc7c8d38&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/utils/filters.py
   **Line:** 65:69
   **Comment:**
        *Custom Rule: Add an explicit type annotation for the `ids` local 
variable in this new function so the variable typing is not implicit.
   
   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%2F41753&comment_hash=2ce2ba9021cc65905c7334e3b834b6e6775f765b90300cf1af693faaba176e25&reaction=like'>👍</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41753&comment_hash=2ce2ba9021cc65905c7334e3b834b6e6775f765b90300cf1af693faaba176e25&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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to