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


##########
superset/mcp_service/chart/schemas.py:
##########
@@ -606,12 +606,17 @@ class ChartFilter(ColumnOperator):
         "datasource_name",
         "created_by_fk",
         "changed_by_fk",
+        "dashboards",

Review Comment:
   **Suggestion:** Adding `dashboards` to the allowed filter columns without 
constraining `opr` for that column creates a validation/runtime contract break: 
requests like `{col:"dashboards", opr:"sw", value:"x"}` pass Pydantic 
validation but later fail in DAO execution with a `ValueError` ("not supported 
on relationship column"). Add a column-aware validator (or a dedicated 
dashboards filter type) so unsupported operators for relationship filters are 
rejected at request-validation time instead of surfacing as runtime tool 
errors. [api mismatch]
   
   <details>
   <summary><b>Severity Level:</b> Major ⚠️</summary>
   
   ```mdx
   - ❌ list_charts crashes on dashboards filters with unsupported operator.
   - ⚠️ MCP clients see runtime errors instead of schema validation feedback.
   - ⚠️ Mismatch between get_schema filter metadata and tool input schema.
   ```
   </details>
   <details>
   <summary><b>Steps of Reproduction ✅ </b></summary>
   
   ```mdx
   1. Note that `ChartFilter` in `superset/mcp_service/chart/schemas.py:595-69` 
defines `col`
   as a Literal including `"dashboards"` and `opr` as `ColumnOperatorEnum`, 
which in
   `superset/daos/base.py:60-75` includes `"sw"` among other operators.
   
   2. Construct a filter object in Python or via MCP params: 
`ChartFilter(col="dashboards",
   opr="sw", value="x")` or the JSON equivalent inside 
`ListChartsRequest(filters=[...])` as
   defined at `superset/mcp_service/chart/schemas.py:1777-59`; Pydantic 
validation succeeds
   because both the column and operator are individually allowed.
   
   3. Call the MCP tool `list_charts` (entrypoint
   `superset/mcp_service/chart/tool/list_charts.py:76-118`) with that 
`ListChartsRequest`;
   `ModelListCore.run_tool` in `superset/mcp_service/mcp_core.py:30-80` passes 
the filters
   through to `ChartDAO.list`, which calls `BaseDAO.apply_column_operators` at
   `superset/daos/base.py:50-75`.
   
   4. In `apply_column_operators`, the `dashboards` attribute is detected as a 
collection
   relationship and dispatched to `_apply_relationship_filter`
   (`superset/daos/base.py:101-150`), which does not support `sw` and raises
   `ValueError("Operator 'sw' is not supported on relationship column 
'dashboards'. Use one
   of: eq, ne, in, nin, is_null, is_not_null.")`, causing `list_charts` to fail 
at runtime
   instead of during request validation.
   ```
   </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=98a45eba6b4244ce8c9c2b34e416c663&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=98a45eba6b4244ce8c9c2b34e416c663&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/schemas.py
   **Line:** 609:609
   **Comment:**
        *Api Mismatch: Adding `dashboards` to the allowed filter columns 
without constraining `opr` for that column creates a validation/runtime 
contract break: requests like `{col:"dashboards", opr:"sw", value:"x"}` pass 
Pydantic validation but later fail in DAO execution with a `ValueError` ("not 
supported on relationship column"). Add a column-aware validator (or a 
dedicated dashboards filter type) so unsupported operators for relationship 
filters are rejected at request-validation time instead of surfacing as runtime 
tool errors.
   
   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%2F40397&comment_hash=f8f6a0a32f135dddf90ccfc564b99cb3c191d774782e710dc3d5b8445858655f&reaction=like'>👍</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F40397&comment_hash=f8f6a0a32f135dddf90ccfc564b99cb3c191d774782e710dc3d5b8445858655f&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