codeant-ai-for-open-source[bot] commented on code in PR #42284:
URL: https://github.com/apache/superset/pull/42284#discussion_r3689313099
##########
superset/mcp_service/chart/chart_utils.py:
##########
@@ -458,18 +458,14 @@ def adhoc_filters_to_query_filters(
Adhoc filters use ``{subject, operator, comparator}`` keys while
``QueryContextFactory`` expects ``{col, op, val}``
(QueryObjectFilterClause).
+ Delegates to the shared builder so the MCP and dashboard-export paths stay
in
+ sync (single source of truth).
"""
- result: list[Dict[str, Any]] = []
- for f in adhoc_filters:
- if f.get("expressionType") == "SIMPLE":
- result.append(
- {
- "col": f.get("subject"),
- "op": f.get("operator"),
- "val": f.get("comparator"),
- }
- )
- return result
+ from superset.common.form_data_query_context import (
+ adhoc_filters_to_query_filters as _shared,
+ )
+
+ return _shared(adhoc_filters)
Review Comment:
**Suggestion:** The delegated helper calls `flt.get(...)` for every item, so
malformed user-supplied `adhoc_filters` entries such as `None` or a scalar now
raise `AttributeError` during MCP compile/preview instead of being skipped.
Preserve the wrapper's defensive filtering of non-dictionary entries or make
the shared helper ignore them before delegation. [null pointer]
<details>
<summary><b>Severity Level:</b> Major ⚠️</summary>
```mdx
- ❌ MCP chart update validation can fail with an unhandled malformed-filter
exception.
- ⚠️ MCP chart previews fail for charts with malformed saved filters.
- ⚠️ Legacy or cached chart form data can preserve invalid filter entries.
```
</details>
[](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=76156c6ea5c9472b9e75ea679843c131&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
[](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=76156c6ea5c9472b9e75ea679843c131&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/chart_utils.py
**Line:** 468:468
**Comment:**
*Null Pointer: The delegated helper calls `flt.get(...)` for every
item, so malformed user-supplied `adhoc_filters` entries such as `None` or a
scalar now raise `AttributeError` during MCP compile/preview instead of being
skipped. Preserve the wrapper's defensive filtering of non-dictionary entries
or make the shared helper ignore them before delegation.
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%2F42284&comment_hash=10709ff4d1dbfacb1a51dd02cdf91725ed643f3ec30dcec8cbefbae1d3d315e4&reaction=like'>👍</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F42284&comment_hash=10709ff4d1dbfacb1a51dd02cdf91725ed643f3ec30dcec8cbefbae1d3d315e4&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]