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


##########
superset-frontend/plugins/plugin-chart-table/src/TableChart.tsx:
##########
@@ -644,9 +658,15 @@ export default function TableChart<D extends DataRecord = 
DataRecord>(
     [comparisonLabels],
   );
 
+  const isTimeComparisonMenuClick = useRef(false);
+
   const renderTimeComparisonDropdown = (): JSX.Element => {
     const allKey = comparisonColumns[0].key;
     const handleOnClick = (data: any) => {

Review Comment:
   **Suggestion:** Replace the `any` type on this dropdown click handler 
parameter with the concrete Ant Design menu click event type (or a minimal 
typed object containing `key`) to keep the code strictly typed. [custom_rule]
   
   **Severity Level:** Minor ⚠️
   <details>
   <summary><b>Why it matters? 🤔 </b></summary>
   
   The final file still contains a modified TypeScript handler parameter typed 
as `any`. This directly violates the rule requiring concrete types in changed 
`.ts`/`.tsx` code.
   </details>
   
   [Fix in 
Cursor](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=5301f4450a8f40e3a5219a5a4c203037&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
 | [Fix in VSCode 
Claude](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=5301f4450a8f40e3a5219a5a4c203037&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-frontend/plugins/plugin-chart-table/src/TableChart.tsx
   **Line:** 665:665
   **Comment:**
        *Custom Rule: Replace the `any` type on this dropdown click handler 
parameter with the concrete Ant Design menu click event type (or a minimal 
typed object containing `key`) to keep the code strictly 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%2F40995&comment_hash=558209253a5eeb1459caffe7b63c45250571568f0377e1721eff74136fc32249&reaction=like'>👍</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F40995&comment_hash=558209253a5eeb1459caffe7b63c45250571568f0377e1721eff74136fc32249&reaction=dislike'>👎</a>



##########
superset-frontend/src/dashboard/util/activeAllDashboardFilters.test.ts:
##########
@@ -315,3 +318,44 @@ test('should return filterState unchanged (clientView 
stripping only applies to
     },
   });
 });
+
+test('should ignore chart ownState-only masks when computing active filters', 
() => {
+  const dataMask: DataMaskStateWithId = {
+    chart101: {
+      id: '101',
+      ownState: {
+        visibleColumns: ['country', 'sales'],
+      },
+    },
+    native1: {
+      id: 'native_1',
+      extraFormData: {
+        filters: [{ col: 'country', op: 'IN', val: ['KG'] }],
+      },
+      filterState: { value: ['KG'] },
+      ownState: {},
+    },
+  };
+
+  const nativeFilters = {
+    native_1: {
+      id: 'native_1',
+      filterType: 'filter_select',
+      chartsInScope: [101, 102],
+      scope: {},
+      targets: [],
+    },
+  } as any;

Review Comment:
   **Suggestion:** Replace the `any` cast with a concrete `nativeFilters` type 
(for example, the dashboard native filter config map type used by 
`getAllActiveFilters`) so the test remains type-safe. [custom_rule]
   
   **Severity Level:** Minor ⚠️
   <details>
   <summary><b>Why it matters? 🤔 </b></summary>
   
   The added test code uses `as any`, which directly violates the rule against 
introducing `any` in changed TypeScript code. This is a real issue in the final 
file state and should be replaced with a concrete nativeFilters type.
   </details>
   
   [Fix in 
Cursor](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=5c7dd90aedfa4184a557677242444700&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
 | [Fix in VSCode 
Claude](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=5c7dd90aedfa4184a557677242444700&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-frontend/src/dashboard/util/activeAllDashboardFilters.test.ts
   **Line:** 348:348
   **Comment:**
        *Custom Rule: Replace the `any` cast with a concrete `nativeFilters` 
type (for example, the dashboard native filter config map type used by 
`getAllActiveFilters`) so the test remains type-safe.
   
   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%2F40995&comment_hash=35b7da34836d64c595e242b6b2db659bdfdeb07a1e58afdb182cc2669e701037&reaction=like'>👍</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F40995&comment_hash=35b7da34836d64c595e242b6b2db659bdfdeb07a1e58afdb182cc2669e701037&reaction=dislike'>👎</a>



##########
superset/mcp_service/dashboard/tool/add_native_filter.py:
##########
@@ -0,0 +1,501 @@
+# 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.
+
+"""
+MCP tool: add_native_filter
+
+This tool adds a native filter to an existing dashboard by updating
+the dashboard's json_metadata.native_filter_configuration.
+"""
+
+import logging
+import uuid
+from datetime import datetime, timezone
+from typing import Any, Dict, List, Literal
+
+from fastmcp import Context
+from pydantic import BaseModel, Field
+from sqlalchemy.exc import SQLAlchemyError
+from superset_core.mcp.decorators import tool, ToolAnnotations
+
+from superset.commands.exceptions import CommandException
+from superset.extensions import event_logger
+from superset.mcp_service.dashboard.schemas import (
+    DashboardError,
+    DashboardInfo,
+    NativeFilterSummary,
+)
+from superset.mcp_service.utils.url_utils import get_superset_base_url
+from superset.utils import json
+
+logger = logging.getLogger(__name__)
+
+
+# ---------------------------------------------------------------------------
+# Request / Response schemas
+# ---------------------------------------------------------------------------
+
+
+class AddNativeFilterRequest(BaseModel):
+    """Request schema for adding a native filter to a dashboard."""
+
+    dashboard_id: int = Field(
+        ..., description="ID of the dashboard to add the filter to"

Review Comment:
   **Suggestion:** Replace this externally exposed integer identifier with a 
UUID-based field in the request schema, and perform any internal integer ID 
lookup server-side to avoid exposing internal numeric IDs through the public 
API contract. [custom_rule]
   
   **Severity Level:** Minor ⚠️
   <details>
   <summary><b>Why it matters? 🤔 </b></summary>
   
   This is a newly added public request schema, and it exposes `dashboard_id` 
as an integer field. The custom rule explicitly flags public API schemas that 
expose internal integer IDs; using a UUID or server-side lookup would avoid 
leaking internal numeric identifiers.
   </details>
   
   [Fix in 
Cursor](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=482ccc85e87b41d1895db01bb4d0091d&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
 | [Fix in VSCode 
Claude](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=482ccc85e87b41d1895db01bb4d0091d&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/dashboard/tool/add_native_filter.py
   **Line:** 55:57
   **Comment:**
        *Custom Rule: Replace this externally exposed integer identifier with a 
UUID-based field in the request schema, and perform any internal integer ID 
lookup server-side to avoid exposing internal numeric IDs through the public 
API contract.
   
   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%2F40995&comment_hash=ce1ba5ab4d40f1f617fdcf205011767b3823c1f25d1585330990abaffea48da1&reaction=like'>👍</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F40995&comment_hash=ce1ba5ab4d40f1f617fdcf205011767b3823c1f25d1585330990abaffea48da1&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