You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by "aminghadersohi (via GitHub)" <gi...@apache.org> on 2026/09/28 07:04:23 UTC
[PR] refactor(mcp): route chart-type behavior through one plugin lifecycle contract [superset]
aminghadersohi opened a new pull request, #44746:
URL: https://github.com/apache/superset/pull/44746
### SUMMARY
The MCP chart tools branch on `viz_type` in several shared modules: query construction (`chart_helpers`), result normalization (`query_result`), the compile check (`compile`), saved-chart previews (`get_chart_preview`), form-data previews (`preview_utils`), update merges (`chart_utils.merge_chart_form_data`) and the update tools' rebind rules. The saved and unsaved preview paths each keep their own copy of the per-chart dispatch. Every new chart type adds another branch to each of these, and the open chart-type PRs each add their own.
This PR puts that per-chart behavior behind one plugin lifecycle contract:
- **Hooks on `BaseChartPlugin`**, each with a default that keeps the shared behavior:
- query construction: `resolve_query_fields`, `build_query_dicts`
- result normalization, applied by compile, previews and (when `normalize_data_results` is set) `get_chart_data` and its CSV/XLSX exports: `normalize_query_result`
- row limits: `compile_row_limit`, `preview_row_limit`
- previews: `ascii_preview`, `vega_lite_preview`
- update and rebind: `resolve_update_config`, `merge_update_form_data`, `validate_merged_form_data`
- **Contract flags** that replace the hard-coded viz-type lists: `requires_compile_check`, `requires_config_for_dataset_rebind`, `unbound_form_data_is_rebind`, `normalize_data_results`, `allows_empty_result`, `resizes_saved_preview`, `supports_column_append`, `preview_note`, `invalid_result_error_code` / `invalid_result_message`, and `additional_viz_types` for saved legacy or sibling viz types (`bubble`, `pop_kpi`).
- **`registry.plugin_for_viz_type()`** resolves the plugin that owns a saved chart's `viz_type`. It ignores runtime enablement, so disabling a type only stops new charts of that type from being created.
- **One dispatcher per concern.** Each shared tool calls that dispatcher instead of branching on viz type. Treemap, Gauge, Gantt, Big Number, Bubble, Mixed Timeseries, Table and Handlebars behavior moves into their plugins as it is.
**Bug fix found by the contract suite:** Histogram charts queried through the shared builder (`get_chart_data`, previews, compile) selected no columns and no metrics. The Histogram plugin now mirrors the frontend `buildQuery` and `histogramOperator`: `[...groupby, column]`, a `COUNT(*)` metric when a HAVING filter is present, and `histogram` post-processing.
**Other visible differences:**
- Saved-chart Vega-Lite previews now call the plugin renderer first, the same order the form-data preview path already used. A saved Bubble chart with zero rows now returns the same empty Bubble spec that an unsaved preview returns, where it used to return `NoDataError`.
- The rebind error for Gauge now uses the plugin display name: "Gauge Chart dataset rebind requires a complete Gauge Chart config."
- `resolve_metrics(form_data, viz_type)` returns Big Number's singular metric, matching `resolve_metrics_and_groupby` and the executed query.
**Registry-wide regression suite** (`test_chart_plugin_contract.py`). It is parametrized over the live registry, so it covers every chart type registered now and any added later. Each registered type must:
- implement every hook and declare typed flags;
- publish at least one schema example;
- own its viz types uniquely, and keep owning them when disabled;
- round-trip the viz type it maps back to itself;
- build non-empty, well-formed queries, and agree with its own `build_query_dicts`;
- handle malformed and failed result envelopes without raising or mutating them;
- return a typed preview or error from every preview format;
- render saved and unsaved Vega-Lite previews from the same renderer;
- keep newly mapped query roles in a same-viz update;
- drop stale roles and filters on a dataset rebind;
- drop every saved control when the viz type changes.
An AST guard also fails if a shared dispatcher compares a viz or chart type against a registered chart type, so new chart types have to use hooks.
**Out of scope:** Jinja `g.form_data` seeding in the compile, preview and form-data `get_chart_data` paths (the gap reported for #40570) is handled by #43176. That PR also carries the approach from #43711 by @Abdulrehman-PIAIC80387. This PR does not touch those call sites, so the two merge independently.
### TESTING INSTRUCTIONS
```bash
pytest tests/unit_tests/mcp_service tests/unit_tests/charts \
tests/unit_tests/common/test_form_data_query_context.py \
tests/unit_tests/common/test_query_context_factory.py \
tests/unit_tests/common/test_query_context_processor.py \
tests/unit_tests/common/test_query_context_processor_timing.py
```
Locally: 6437 passed, 4 skipped, 2 xfailed. The new Histogram test fails on master (the query selects only `['region']`) and passes with this change.
Manual check: call `get_chart_data` on a saved Histogram chart. It returns binned rows instead of failing on an empty query. Treemap, Gauge and Gantt previews, `update_chart` and `update_chart_preview` behave as before.
### ADDITIONAL INFORMATION
- [ ] Has associated issue:
- [ ] Required feature flags:
- [ ] 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
- [ ] Introduces new feature or API
- [ ] Removes existing feature or API
๐ค Generated with [Claude Code](https://claude.com/claude-code)
--
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] refactor(mcp): one plugin lifecycle contract and compact chart config schemas [superset]
Posted by "aminghadersohi (via GitHub)" <gi...@apache.org>.
aminghadersohi commented on PR #44746:
URL: https://github.com/apache/superset/pull/44746#issuecomment-5894823441
Retest #2: all three reported oversized chart tools are already covered by the shared compact chart-config annotation at the PR head; no additional production compaction is needed.
Measured complete definitions as UTF-8 compact JSON (not just inputSchema, and without subtracting the chart-type enum). Native search definitions are normalized through MCP Tool validation and the gateway's metadata alias / exclude_unset serialization; direct tools/list retains output schemas and full descriptions:
| Tool | Reporter-observed before | PR head native search | PR head direct catalog |
| --- | ---: | ---: | ---: |
| update_chart_preview | 112,956 B | 2,004 B | 3,551 B |
| generate_explore_link | 106,800 B | 1,837 B | 8,157 B |
| update_chart | 114,991 B | 4,077 B | 26,769 B |
The before values are the reporter's measurements, not a reproduction against a customer workspace. A single-item gateway page adds two bytes for brackets. Added regression tests pinning the entire page below 100,000 bytes for both catalog paths and all four chart tools. Expanded FastMCP invalid-per-type-field validation coverage to all four request models; no runtime validation was weakened.
Rechecked @rebenitez1802's change-request review and threads: the empty-result flag gates both plugin and generic rendering; all five intentional empty renderers opt in; Histogram's behavior is documented in UPDATING.md and the MCP docs; the AST guard scans whole modules and structurally checks comparisons/dictionary keys/get operands with mutation regressions; Histogram's comment explicitly distinguishes MCP top-level having support. The earlier master conflict is resolved and the PR is mergeable, so no additional merge is needed.
Validation: 507 focused inventory/contract tests passed; branch-scoped pre-commit (including mypy and pylint) passed apart from a formatting auto-fix, followed by a clean staged pre-commit run.
--
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] refactor(mcp): one plugin lifecycle contract and compact chart config schemas [superset]
Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on code in PR #44746:
URL: https://github.com/apache/superset/pull/44746#discussion_r4121503906
##########
tests/unit_tests/mcp_service/chart/tool/test_get_chart_data.py:
##########
@@ -3488,3 +3488,40 @@ def run(self) -> dict[str, Any]:
await client.call_tool("get_chart_data", {"request": {"identifier": "11"}})
assert captured["order_desc"] is False
+
+
+@pytest.mark.asyncio
+@pytest.mark.parametrize(
+ "invalid_fields, message",
+ [
+ ({"start_time": None}, "start_time"),
+ ({"end_time": None}, "end_time"),
+ ({"y_axis": None}, "y_axis"),
+ ({"tooltip_columns": ["task"] * 51}, "tooltip_columns"),
+ ({"order_by_cols": [["start", "yes"]]}, "ascending_boolean"),
+ ],
Review Comment:
<div>
<div id="suggestion">
<div id="issue"><b>Missing tooltip_metrics case</b></div>
<div id="fix">
The parametrize set covers `tooltip_columns` overflow but omits `tooltip_metrics`, which `resolve_gantt_query_fields` validates identically (`Gantt tooltip_metrics must contain at most 50 entries`, chart_helpers.py:626-627). No test in this file exercises `tooltip_metrics` (grep: 0 matches). Adding one parametrize case closes the gap in the docstring's promised "malformed cached Gantt roles" coverage.
</div>
</div>
<small><i>Code Review Run #bd88ea</i></small>
</div>
---
Should Bito avoid suggestions like this for future reviews? (<a href=https://alpha.bito.ai/home/ai-agents/review-rules>Manage Rules</a>)
- [ ] Yes, avoid them
##########
tests/unit_tests/mcp_service/chart/tool/test_get_chart_data.py:
##########
@@ -3488,3 +3488,40 @@ def run(self) -> dict[str, Any]:
await client.call_tool("get_chart_data", {"request": {"identifier": "11"}})
assert captured["order_desc"] is False
+
+
+@pytest.mark.asyncio
+@pytest.mark.parametrize(
+ "invalid_fields, message",
+ [
+ ({"start_time": None}, "start_time"),
+ ({"end_time": None}, "end_time"),
+ ({"y_axis": None}, "y_axis"),
+ ({"tooltip_columns": ["task"] * 51}, "tooltip_columns"),
+ ({"order_by_cols": [["start", "yes"]]}, "ascending_boolean"),
+ ],
+)
+async def test_malformed_gantt_query_returns_validation_error(
+ invalid_fields: dict[str, Any],
+ message: str,
+) -> None:
+ """Reject malformed cached Gantt roles without reporting an internal failure."""
+ with patch(
+ "superset.mcp_service.chart.chart_helpers.resolve_datasource_engine",
+ return_value="sqlite",
+ ):
Review Comment:
<div>
<div id="suggestion">
<div id="issue"><b>Inconsistent mock pattern</b></div>
<div id="fix">
`resolve_datasource_engine` is patched with `patch(..., return_value="sqlite")`, but its real signature takes `(datasource_id, datasource_type)` (chart_helpers.py:180). A MagicMock swallows any call, so a future signature change would go undetected here. Sibling tests in this file use `monkeypatch.setattr` with lambdas (lines 572-575, 2474-2477); following that pattern keeps mocking consistent and signature-sensitive.
</div>
</div>
<details>
<summary><b>Citations</b></summary>
<ul>
<li>
Rule Violated: <a href="https://github.com/apache/superset/blob/49b2e0a/.cursor/rules/dev-standard.mdc#L119">dev-standard.mdc:119</a>
</li>
</ul>
</details>
<small><i>Code Review Run #bd88ea</i></small>
</div>
---
Should Bito avoid suggestions like this for future reviews? (<a href=https://alpha.bito.ai/home/ai-agents/review-rules>Manage Rules</a>)
- [ ] Yes, avoid them
##########
superset/mcp_service/chart/plugins/treemap.py:
##########
@@ -150,3 +162,114 @@ def schema_error_hint(self) -> ChartGenerationError | None:
],
error_code="TREEMAP_VALIDATION_ERROR",
)
+
+ def resolve_query_fields(
+ self, form_data: Mapping[str, Any], viz_type: str
+ ) -> tuple[list[Any], list[Any]] | None:
+ # Treemap has exactly these roles; stale controls from another plugin
+ # must not override its singular metric or ordered hierarchy.
+ metric = form_data.get("metric")
+ hierarchy = form_data.get("groupby") or []
+ return ([metric] if metric else []), (
+ [hierarchy] if isinstance(hierarchy, str) else list(hierarchy)
+ )
+
+ def build_query_dicts(
+ self,
+ form_data: dict[str, Any],
+ *,
+ viz_type: str,
+ engine: str,
+ row_limit: int | None,
+ order_desc: bool | None,
+ ) -> list[dict[str, Any]] | None:
+ from superset.mcp_service.chart.chart_helpers import (
+ apply_treemap_query_fields,
+ build_single_query_dict,
+ )
+
+ metrics, hierarchy = cast(
+ tuple[list[Any], list[Any]],
+ self.resolve_query_fields(form_data, viz_type),
+ )
+ query = build_single_query_dict(
+ form_data,
+ hierarchy,
+ metrics,
+ row_limit=row_limit,
+ order_desc=order_desc,
+ )
+ apply_treemap_query_fields(
+ query,
+ form_data,
+ hierarchy,
+ row_limit if row_limit is not None else form_data.get("row_limit"),
+ )
+ return [query]
+
+ def normalize_query_result(self, result: Any, form_data: Mapping[str, Any]) -> Any:
+ from superset.mcp_service.chart.query_result import (
+ normalize_treemap_query_result,
+ )
+
+ return normalize_treemap_query_result(result, form_data)
+
+ def compile_row_limit(self, form_data: Mapping[str, Any]) -> int:
+ try:
+ limit = int(form_data.get("row_limit") or 10)
+ except (TypeError, ValueError, OverflowError):
+ return 10
+ return min(10, limit) if limit > 0 else 10
Review Comment:
<div>
<div id="suggestion">
<div id="issue"><b>Magic numbers encode limit policy</b></div>
<div id="fix">
The changed lines hardcode the business policy three times: `or 10` (fallback for absent/falsy `row_limit`), `return 10` (fallback for unparseable values), and `min(10, ...)` (cap). The cap and the fallback coincidentally share the value 10, but nothing distinguishes 'default when unset' from 'maximum allowed for the compile check', so a future change to one (e.g. raising the cap) will likely miss the other. The sibling `preview_row_limit` (lines 224-230) hardcodes 100/10000 the same way. Please extract named constants for the fallback and the cap.
</div>
</div>
<small><i>Code Review Run #bd88ea</i></small>
</div>
---
Should Bito avoid suggestions like this for future reviews? (<a href=https://alpha.bito.ai/home/ai-agents/review-rules>Manage Rules</a>)
- [ ] Yes, avoid them
##########
superset/mcp_service/chart/preview_utils.py:
##########
@@ -1257,19 +1275,129 @@ def generate_bubble_vega_lite_preview(
)
+# Native geometries the Vega-Lite adapter cannot represent faithfully.
+_UNSUPPORTED_VEGA_GEOMETRIES: frozenset[str] = frozenset(
+ {"sankey", "sankey_v2", "radar"}
+)
+
+
+def unsupported_vega_geometry(viz_type: str) -> ChartError | None:
+ """Reject native geometries the Vega-Lite adapter cannot represent."""
+ if viz_type not in _UNSUPPORTED_VEGA_GEOMETRIES:
+ return None
+ return ChartError(
+ error=(
+ f"Vega-Lite previews do not support {viz_type} geometry. "
+ "Use Explore for the native visualization or ASCII/table for data."
+ ),
+ error_type="UnsupportedFormat",
+ )
+
+
+def generate_funnel_vega_lite_preview(
+ data: list[dict[str, Any]], form_data: dict[str, Any]
+) -> VegaLitePreview | ChartError:
+ """Render funnel stages as horizontal value bars, preserving query order."""
+ from superset.utils.core import get_column_name
+
+ groupby = form_data.get("groupby") or []
+ metric = metric_result_label(form_data.get("metric"))
+ if not groupby or not metric:
+ return ChartError(
+ error="Funnel requires a stage and metric", error_type="InvalidFormData"
+ )
+ stage = get_column_name(groupby[0])
Review Comment:
<div>
<div id="suggestion">
<div id="issue"><b>Unguarded ValueError from get_column_name</b></div>
<div id="fix">
`generate_funnel_vega_lite_preview` calls `get_column_name(groupby[0])` unguarded. Per `superset/utils/core.py:1391`, `get_column_name` raises `ValueError("Missing label")` for any entry that is not a str, dict with label/sqlExpression, or object with column_name. `groupby` comes straight from `form_data` (line 1303) with no shape validation, unlike the gauge path (lines 816-829) which validates each entry. A malformed stage entry raises ValueError instead of returning the `ChartError` contract; the caller's except tuple does catch ValueError, but the failure is then mislabeled `VegaLiteGenerationError` rather than `InvalidFormData`.
</div>
</div>
<small><i>Code Review Run #bd88ea</i></small>
</div>
---
Should Bito avoid suggestions like this for future reviews? (<a href=https://alpha.bito.ai/home/ai-agents/review-rules>Manage Rules</a>)
- [ ] Yes, avoid them
--
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] refactor(mcp): one plugin lifecycle contract and compact chart config schemas [superset]
Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #44746:
URL: https://github.com/apache/superset/pull/44746#issuecomment-5892700075
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 an incremental AI Review.
- `/review full` - 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] refactor(mcp): one plugin lifecycle contract and compact chart config schemas [superset]
Posted by "aminghadersohi (via GitHub)" <gi...@apache.org>.
aminghadersohi merged PR #44746:
URL: https://github.com/apache/superset/pull/44746
--
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] refactor(mcp): route chart-type behavior through one plugin lifecycle contract [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 #44746:
URL: https://github.com/apache/superset/pull/44746#discussion_r4119453168
##########
superset/mcp_service/chart/tool/update_chart.py:
##########
@@ -866,19 +869,26 @@ async def update_chart( # noqa: C901
# config is already a typed ChartConfig | None (validated by Pydantic)
try:
+ config_plugin = (
+ get_registry().get(request.config.chart_type)
+ if request.config is not None
+ else None
Review Comment:
**Suggestion:** `get()` hides disabled plugins, so updates to saved charts of disabled types skip their lifecycle hooks and map or merge configuration incorrectly.
**Assessment:** ๐ `Major` ยท ๐ `Occurrence: Sometimes` ยท ๐ท๏ธ `Api mismatch`
[](https://docs.codeant.ai/cli/resolve-pr-comments-skill) [](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=066c53e2cf9b4aa1895f10c9550c3729&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=066c53e2cf9b4aa1895f10c9550c3729&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
<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/update_chart.py
**Line:** 872:875
**Comment:**
*Api Mismatch: `get()` hides disabled plugins, so updates to saved charts of disabled types skip their lifecycle hooks and map or merge configuration incorrectly.
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%2F44746&comment_hash=2cda36249651694dbdb4f65ef8d8986906b672d3636d0b7bf91a4174d7abee4b&reaction=like'>๐</a> | <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F44746&comment_hash=2cda36249651694dbdb4f65ef8d8986906b672d3636d0b7bf91a4174d7abee4b&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] refactor(mcp): one plugin lifecycle contract and compact chart config schemas [superset]
Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on code in PR #44746:
URL: https://github.com/apache/superset/pull/44746#discussion_r4121935445
##########
superset/mcp_service/chart/plugins/treemap.py:
##########
@@ -150,3 +162,114 @@ def schema_error_hint(self) -> ChartGenerationError | None:
],
error_code="TREEMAP_VALIDATION_ERROR",
)
+
+ def resolve_query_fields(
+ self, form_data: Mapping[str, Any], viz_type: str
+ ) -> tuple[list[Any], list[Any]] | None:
+ # Treemap has exactly these roles; stale controls from another plugin
+ # must not override its singular metric or ordered hierarchy.
+ metric = form_data.get("metric")
+ hierarchy = form_data.get("groupby") or []
+ return ([metric] if metric else []), (
+ [hierarchy] if isinstance(hierarchy, str) else list(hierarchy)
+ )
+
+ def build_query_dicts(
+ self,
+ form_data: dict[str, Any],
+ *,
+ viz_type: str,
+ engine: str,
+ row_limit: int | None,
+ order_desc: bool | None,
+ ) -> list[dict[str, Any]] | None:
+ from superset.mcp_service.chart.chart_helpers import (
+ apply_treemap_query_fields,
+ build_single_query_dict,
+ )
+
+ metrics, hierarchy = cast(
+ tuple[list[Any], list[Any]],
+ self.resolve_query_fields(form_data, viz_type),
+ )
+ query = build_single_query_dict(
+ form_data,
+ hierarchy,
+ metrics,
+ row_limit=row_limit,
+ order_desc=order_desc,
+ )
+ apply_treemap_query_fields(
+ query,
+ form_data,
+ hierarchy,
+ row_limit if row_limit is not None else form_data.get("row_limit"),
+ )
+ return [query]
+
+ def normalize_query_result(self, result: Any, form_data: Mapping[str, Any]) -> Any:
+ from superset.mcp_service.chart.query_result import (
+ normalize_treemap_query_result,
+ )
+
+ return normalize_treemap_query_result(result, form_data)
+
+ def compile_row_limit(self, form_data: Mapping[str, Any]) -> int:
+ try:
+ limit = int(form_data.get("row_limit") or 10)
+ except (TypeError, ValueError, OverflowError):
+ return 10
+ return min(10, limit) if limit > 0 else 10
Review Comment:
<!-- Bito Reply -->
The decision to keep the row limit logic localized within the method is reasonable, as it maintains clear ownership of the policy for this specific plugin. Since the fallback and cap values are intentionally distinct for different contexts, extracting them into constants would not necessarily improve clarity or prevent errors in this case. Your approach of keeping the policy encapsulated within the method is a valid design choice.
##########
tests/unit_tests/mcp_service/chart/tool/test_get_chart_data.py:
##########
@@ -3488,3 +3488,40 @@ def run(self) -> dict[str, Any]:
await client.call_tool("get_chart_data", {"request": {"identifier": "11"}})
assert captured["order_desc"] is False
+
+
+@pytest.mark.asyncio
+@pytest.mark.parametrize(
+ "invalid_fields, message",
+ [
+ ({"start_time": None}, "start_time"),
+ ({"end_time": None}, "end_time"),
+ ({"y_axis": None}, "y_axis"),
+ ({"tooltip_columns": ["task"] * 51}, "tooltip_columns"),
+ ({"order_by_cols": [["start", "yes"]]}, "ascending_boolean"),
+ ],
Review Comment:
<!-- Bito Reply -->
The suggestion provided by the reviewer is appropriate. It correctly identifies that the `tooltip_metrics` field was missing validation coverage in the test suite, mirroring the existing validation logic in the application code. Adding this test case ensures that the `tooltip_metrics` field is properly validated, consistent with the other fields in the `parametrize` set.
**tests/unit_tests/mcp_service/chart/tool/test_get_chart_data.py**
```
{"tooltip_columns": ["task"] * 51}, "tooltip_columns"),
{"tooltip_metrics": ["metric"] * 51}, "tooltip_metrics"),
{"order_by_cols": [["start", "yes"]]}, "ascending_boolean"),
```
##########
tests/unit_tests/mcp_service/chart/tool/test_get_chart_data.py:
##########
@@ -3488,3 +3488,40 @@ def run(self) -> dict[str, Any]:
await client.call_tool("get_chart_data", {"request": {"identifier": "11"}})
assert captured["order_desc"] is False
+
+
+@pytest.mark.asyncio
+@pytest.mark.parametrize(
+ "invalid_fields, message",
+ [
+ ({"start_time": None}, "start_time"),
+ ({"end_time": None}, "end_time"),
+ ({"y_axis": None}, "y_axis"),
+ ({"tooltip_columns": ["task"] * 51}, "tooltip_columns"),
+ ({"order_by_cols": [["start", "yes"]]}, "ascending_boolean"),
+ ],
+)
+async def test_malformed_gantt_query_returns_validation_error(
+ invalid_fields: dict[str, Any],
+ message: str,
+) -> None:
+ """Reject malformed cached Gantt roles without reporting an internal failure."""
+ with patch(
+ "superset.mcp_service.chart.chart_helpers.resolve_datasource_engine",
+ return_value="sqlite",
+ ):
Review Comment:
<!-- Bito Reply -->
The suggestion to use `monkeypatch.setattr` with a lambda is a valid alternative that improves test robustness by ensuring the mock remains sensitive to the function's signature. While the current `patch` approach is functional for isolating the engine lookup, adopting the suggested pattern aligns with existing test standards in the file and prevents potential silent failures if the function signature changes in the future.
**tests/unit_tests/mcp_service/chart/tool/test_get_chart_data.py**
```
with patch(
"superset.mcp_service.chart.chart_helpers.resolve_datasource_engine",
return_value="sqlite",
):
```
##########
superset/mcp_service/chart/preview_utils.py:
##########
@@ -1257,19 +1275,129 @@ def generate_bubble_vega_lite_preview(
)
+# Native geometries the Vega-Lite adapter cannot represent faithfully.
+_UNSUPPORTED_VEGA_GEOMETRIES: frozenset[str] = frozenset(
+ {"sankey", "sankey_v2", "radar"}
+)
+
+
+def unsupported_vega_geometry(viz_type: str) -> ChartError | None:
+ """Reject native geometries the Vega-Lite adapter cannot represent."""
+ if viz_type not in _UNSUPPORTED_VEGA_GEOMETRIES:
+ return None
+ return ChartError(
+ error=(
+ f"Vega-Lite previews do not support {viz_type} geometry. "
+ "Use Explore for the native visualization or ASCII/table for data."
+ ),
+ error_type="UnsupportedFormat",
+ )
+
+
+def generate_funnel_vega_lite_preview(
+ data: list[dict[str, Any]], form_data: dict[str, Any]
+) -> VegaLitePreview | ChartError:
+ """Render funnel stages as horizontal value bars, preserving query order."""
+ from superset.utils.core import get_column_name
+
+ groupby = form_data.get("groupby") or []
+ metric = metric_result_label(form_data.get("metric"))
+ if not groupby or not metric:
+ return ChartError(
+ error="Funnel requires a stage and metric", error_type="InvalidFormData"
+ )
+ stage = get_column_name(groupby[0])
Review Comment:
<!-- Bito Reply -->
The suggestion provided by the reviewer is appropriate and improves the code. It correctly identifies that `get_column_name` can raise a `ValueError` when encountering malformed input, and wrapping this call ensures the function adheres to the expected `ChartError` contract instead of allowing an unhandled exception to propagate.
**superset/mcp_service/chart/preview_utils.py**
```
try:
stage = get_column_name(groupby[0])
except ValueError:
return ChartError(
error=f"Invalid funnel stage: {groupby[0]}", error_type="InvalidFormData"
)
```
--
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] refactor(mcp): route chart-type behavior through one plugin lifecycle contract [superset]
Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on code in PR #44746:
URL: https://github.com/apache/superset/pull/44746#discussion_r4119770169
##########
superset/mcp_service/chart/tool/update_chart.py:
##########
@@ -866,19 +867,26 @@ async def update_chart( # noqa: C901
# config is already a typed ChartConfig | None (validated by Pydantic)
try:
+ config_plugin = (
+ get_registry().get(request.config.chart_type)
+ if request.config is not None
+ else None
+ )
parsed_config = (
- resolve_treemap_update_config(
+ config_plugin.resolve_update_config(
Review Comment:
<div>
<div id="suggestion">
<div id="issue"><b>CWE-470: Disabled plugin skips config completion</b></div>
<div id="fix">
`get_registry().get()` returns None for disabled plugins, but this is a saved-chart update path: the `plugin_for_viz_type` contract (registry.py) says saved charts must be updated with their plugin's contract even when creating new charts is disabled. With `treemap_v2` in `MCP_DISABLED_CHART_PLUGINS`, a partial `TreemapChartUpdateConfig` skips `resolve_update_config` role completion, so updating an existing treemap fails validation. Sibling lookups at lines 158, 591, 820 use `plugin_for_viz_type`. ([CWE-470](https://cwe.mitre.org/data/definitions/470.html))
</div>
</div>
<details>
<summary><b>Citations</b></summary>
<ul>
<li>
Rule Violated: <a href="https://github.com/apache/superset/blob/8d95326/.cursor/rules/dev-standard.mdc#L119">dev-standard.mdc:119</a>
</li>
</ul>
</details>
<small><i>Code Review Run #d830d4</i></small>
</div>
---
Should Bito avoid suggestions like this for future reviews? (<a href=https://alpha.bito.ai/home/ai-agents/review-rules>Manage Rules</a>)
- [ ] Yes, avoid them
##########
superset/mcp_service/chart/plugins/gantt.py:
##########
@@ -235,3 +243,66 @@ def schema_error_hint(self) -> ChartGenerationError | None:
],
error_code="GANTT_VALIDATION_ERROR",
)
+
+ def build_query_dicts(
+ self,
+ form_data: dict[str, Any],
+ *,
+ viz_type: str,
+ engine: str,
+ row_limit: int | None,
+ order_desc: bool | None,
+ ) -> list[dict[str, Any]] | None:
+ from superset.mcp_service.chart.chart_helpers import (
+ build_single_query_dict,
+ resolve_gantt_query_fields,
+ )
+
+ columns, metrics, orderby, series_columns = resolve_gantt_query_fields(
+ form_data
+ )
+ query = build_single_query_dict(
+ form_data, columns, metrics, row_limit=row_limit
+ )
+ query["orderby"] = orderby
+ query["series_columns"] = series_columns
Review Comment:
<div>
<div id="suggestion">
<div id="issue"><b>Uncaught ValueError</b></div>
<div id="fix">
`resolve_gantt_query_fields` raises `ValueError` on malformed form_data (missing `start_time`/`end_time`/`y_axis`, oversized tooltip lists). This propagates uncaught through `build_query_dicts_from_form_data` โ `build_query_context_from_form_data` into `get_chart_data`, where the generic `except (... ValueError ...)` (get_chart_data.py:1104) turns it into a generic `InternalError`/`DataError`. The base contract says `build_query_dicts` returns `None` to fall back to the shared builder; consider catching and returning `None` or a structured error.
</div>
</div>
<small><i>Code Review Run #d830d4</i></small>
</div>
---
Should Bito avoid suggestions like this for future reviews? (<a href=https://alpha.bito.ai/home/ai-agents/review-rules>Manage Rules</a>)
- [ ] Yes, avoid them
##########
superset/mcp_service/chart/plugins/treemap.py:
##########
@@ -150,3 +162,110 @@ def schema_error_hint(self) -> ChartGenerationError | None:
],
error_code="TREEMAP_VALIDATION_ERROR",
)
+
+ def resolve_query_fields(
+ self, form_data: Mapping[str, Any], viz_type: str
+ ) -> tuple[list[Any], list[Any]] | None:
+ # Treemap has exactly these roles; stale controls from another plugin
+ # must not override its singular metric or ordered hierarchy.
+ metric = form_data.get("metric")
+ hierarchy = form_data.get("groupby") or []
+ return ([metric] if metric else []), (
+ [hierarchy] if isinstance(hierarchy, str) else list(hierarchy)
+ )
+
+ def build_query_dicts(
+ self,
+ form_data: dict[str, Any],
+ *,
+ viz_type: str,
+ engine: str,
+ row_limit: int | None,
+ order_desc: bool | None,
+ ) -> list[dict[str, Any]] | None:
+ from superset.mcp_service.chart.chart_helpers import (
+ apply_treemap_query_fields,
+ build_single_query_dict,
+ )
+
+ metrics, hierarchy = cast(
+ tuple[list[Any], list[Any]],
+ self.resolve_query_fields(form_data, viz_type),
+ )
+ query = build_single_query_dict(
+ form_data,
+ hierarchy,
+ metrics,
+ row_limit=row_limit,
+ order_desc=order_desc,
+ )
+ apply_treemap_query_fields(
+ query,
+ form_data,
+ hierarchy,
+ row_limit if row_limit is not None else form_data.get("row_limit"),
+ )
+ return [query]
+
+ def normalize_query_result(self, result: Any, form_data: Mapping[str, Any]) -> Any:
+ from superset.mcp_service.chart.query_result import (
+ normalize_treemap_query_result,
+ )
+
+ return normalize_treemap_query_result(result, form_data)
+
+ def compile_row_limit(self, form_data: Mapping[str, Any]) -> int:
Review Comment:
<div>
<div id="suggestion">
<div id="issue"><b>CWE-20: Unguarded int() row limit</b></div>
<div id="fix">
`compile_row_limit` calls `int(form_data.get("row_limit") or 10)` unguarded, while sibling `preview_row_limit` (same diff) catches TypeError/ValueError/OverflowError for the same value. A non-numeric `row_limit` in persisted chart params raises ValueError inside `_compile_chart` (compile.py:116), yielding a cryptic CHART_COMPILE_FAILED instead of the fallback; TypeError escapes compile.py:188's except tuple. Mirror the sibling's guard. ([CWE-20](https://cwe.mitre.org/data/definitions/20.html))
</div>
</div>
<small><i>Code Review Run #d830d4</i></small>
</div>
---
Should Bito avoid suggestions like this for future reviews? (<a href=https://alpha.bito.ai/home/ai-agents/review-rules>Manage Rules</a>)
- [ ] Yes, avoid them
--
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] refactor(mcp): one plugin lifecycle contract and compact chart config schemas [superset]
Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #44746:
URL: https://github.com/apache/superset/pull/44746#issuecomment-5911793919
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 an incremental AI Review.
- `/review full` - 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] refactor(mcp): route chart-type behavior through one plugin lifecycle contract [superset]
Posted by "codecov[bot] (via GitHub)" <gi...@apache.org>.
codecov[bot] commented on PR #44746:
URL: https://github.com/apache/superset/pull/44746#issuecomment-5865370497
## [Codecov](https://app.codecov.io/gh/apache/superset/pull/44746?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 `90.90909%` with `33 lines` in your changes missing coverage. Please review.
:white_check_mark: Project coverage is 77.71%. Comparing base ([`ffe9a00`](https://app.codecov.io/gh/apache/superset/commit/ffe9a00fc42635287310eab08ad664c00759c4fc?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`8d95326`](https://app.codecov.io/gh/apache/superset/commit/8d953262e0d378efdc07f45e885ec5d07cee0e35?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
| [Files with missing lines](https://app.codecov.io/gh/apache/superset/pull/44746?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/chart/plugin.py](https://app.codecov.io/gh/apache/superset/pull/44746?src=pr&el=tree&filepath=superset%2Fmcp_service%2Fchart%2Fplugin.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3VwZXJzZXQvbWNwX3NlcnZpY2UvY2hhcnQvcGx1Z2luLnB5) | 84.37% | [10 Missing :warning: ](https://app.codecov.io/gh/apache/superset/pull/44746?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
| [superset/mcp\_service/chart/plugins/treemap.py](https://app.codecov.io/gh/apache/superset/pull/44746?src=pr&el=tree&filepath=superset%2Fmcp_service%2Fchart%2Fplugins%2Ftreemap.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3VwZXJzZXQvbWNwX3NlcnZpY2UvY2hhcnQvcGx1Z2lucy90cmVlbWFwLnB5) | 90.90% | [3 Missing and 1 partial :warning: ](https://app.codecov.io/gh/apache/superset/pull/44746?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
| [superset/mcp\_service/chart/preview\_utils.py](https://app.codecov.io/gh/apache/superset/pull/44746?src=pr&el=tree&filepath=superset%2Fmcp_service%2Fchart%2Fpreview_utils.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3VwZXJzZXQvbWNwX3NlcnZpY2UvY2hhcnQvcHJldmlld191dGlscy5weQ==) | 80.95% | [2 Missing and 2 partials :warning: ](https://app.codecov.io/gh/apache/superset/pull/44746?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
| [superset/mcp\_service/chart/plugins/histogram.py](https://app.codecov.io/gh/apache/superset/pull/44746?src=pr&el=tree&filepath=superset%2Fmcp_service%2Fchart%2Fplugins%2Fhistogram.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3VwZXJzZXQvbWNwX3NlcnZpY2UvY2hhcnQvcGx1Z2lucy9oaXN0b2dyYW0ucHk=) | 86.36% | [2 Missing and 1 partial :warning: ](https://app.codecov.io/gh/apache/superset/pull/44746?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
| [superset/mcp\_service/chart/plugins/gantt.py](https://app.codecov.io/gh/apache/superset/pull/44746?src=pr&el=tree&filepath=superset%2Fmcp_service%2Fchart%2Fplugins%2Fgantt.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3VwZXJzZXQvbWNwX3NlcnZpY2UvY2hhcnQvcGx1Z2lucy9nYW50dC5weQ==) | 90.90% | [1 Missing and 1 partial :warning: ](https://app.codecov.io/gh/apache/superset/pull/44746?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
| [superset/mcp\_service/chart/plugins/gauge.py](https://app.codecov.io/gh/apache/superset/pull/44746?src=pr&el=tree&filepath=superset%2Fmcp_service%2Fchart%2Fplugins%2Fgauge.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3VwZXJzZXQvbWNwX3NlcnZpY2UvY2hhcnQvcGx1Z2lucy9nYXVnZS5weQ==) | 91.66% | [1 Missing and 1 partial :warning: ](https://app.codecov.io/gh/apache/superset/pull/44746?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
| [superset/mcp\_service/chart/query\_result.py](https://app.codecov.io/gh/apache/superset/pull/44746?src=pr&el=tree&filepath=superset%2Fmcp_service%2Fchart%2Fquery_result.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3VwZXJzZXQvbWNwX3NlcnZpY2UvY2hhcnQvcXVlcnlfcmVzdWx0LnB5) | 66.66% | [1 Missing and 1 partial :warning: ](https://app.codecov.io/gh/apache/superset/pull/44746?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
| [...perset/mcp\_service/chart/tool/get\_chart\_preview.py](https://app.codecov.io/gh/apache/superset/pull/44746?src=pr&el=tree&filepath=superset%2Fmcp_service%2Fchart%2Ftool%2Fget_chart_preview.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3VwZXJzZXQvbWNwX3NlcnZpY2UvY2hhcnQvdG9vbC9nZXRfY2hhcnRfcHJldmlldy5weQ==) | 91.30% | [0 Missing and 2 partials :warning: ](https://app.codecov.io/gh/apache/superset/pull/44746?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
| [superset/mcp\_service/chart/chart\_utils.py](https://app.codecov.io/gh/apache/superset/pull/44746?src=pr&el=tree&filepath=superset%2Fmcp_service%2Fchart%2Fchart_utils.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3VwZXJzZXQvbWNwX3NlcnZpY2UvY2hhcnQvY2hhcnRfdXRpbHMucHk=) | 96.87% | [0 Missing and 1 partial :warning: ](https://app.codecov.io/gh/apache/superset/pull/44746?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
| [superset/mcp\_service/chart/registry.py](https://app.codecov.io/gh/apache/superset/pull/44746?src=pr&el=tree&filepath=superset%2Fmcp_service%2Fchart%2Fregistry.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3VwZXJzZXQvbWNwX3NlcnZpY2UvY2hhcnQvcmVnaXN0cnkucHk=) | 93.75% | [1 Missing :warning: ](https://app.codecov.io/gh/apache/superset/pull/44746?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
| ... and [2 more](https://app.codecov.io/gh/apache/superset/pull/44746?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | |
<details><summary>Additional details and impacted files</summary>
```diff
@@ Coverage Diff @@
## master #44746 +/- ##
==========================================
- Coverage 81.22% 77.71% -3.51%
==========================================
Files 2968 2968
Lines 179363 179570 +207
Branches 41597 41594 -3
==========================================
- Hits 145681 139549 -6132
- Misses 30971 37164 +6193
- Partials 2711 2857 +146
```
| [Flag](https://app.codecov.io/gh/apache/superset/pull/44746/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/44746/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `36.75% <32.50%> (+0.01%)` | :arrow_up: |
| [mysql](https://app.codecov.io/gh/apache/superset/pull/44746/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/44746/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/44746/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `38.65% <32.50%> (+0.01%)` | :arrow_up: |
| [python](https://app.codecov.io/gh/apache/superset/pull/44746/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `78.71% <90.90%> (-6.78%)` | :arrow_down: |
| [sqlite](https://app.codecov.io/gh/apache/superset/pull/44746/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/44746/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `77.89% <90.90%> (+0.10%)` | :arrow_up: |
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/44746?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] refactor(mcp): route chart-type behavior through one plugin lifecycle contract [superset]
Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #44746:
URL: https://github.com/apache/superset/pull/44746#issuecomment-5865100237
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] refactor(mcp): one plugin lifecycle contract and compact chart config schemas [superset]
Posted by "aminghadersohi (via GitHub)" <gi...@apache.org>.
aminghadersohi commented on PR #44746:
URL: https://github.com/apache/superset/pull/44746#issuecomment-5908590037
Review follow-up:
- rebenitez1802's approved review (5356562885): the complete body confirms the earlier feedback is resolved; no further change requests.
- Bito's duplicated request-key suggestion (5897718375): addressed in 09179a33aebd0318606e070e6979900651a75eed. Both inventory tests use `_request_key(name)`, with a parameterized regression test covering all four chart tools.
Merged Apache master in 7645c1c01f6051b4c2bdcf3925091658213e2b41 without rewriting history. The sole conflict was `UPDATING.md`; both the MCP upgrade notes and master's upgrade notes were retained. #44744 remains open, so no alternative histogram/waterfall implementation required adaptation.
Validation: MCP unit suite **6,206 passed, 4 skipped**, using the repository-required FastMCP 3.4.7 and local `superset-core/src` on `PYTHONPATH`. The initial run with outdated FastMCP 3.4.2 had three catalog middleware signature failures; all pass with 3.4.7. Pre-commit passed on all 35 PR-changed files, including mypy and pylint.
--
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] refactor(mcp): one plugin lifecycle contract and compact chart config schemas [superset]
Posted by "aminghadersohi (via GitHub)" <gi...@apache.org>.
aminghadersohi commented on code in PR #44746:
URL: https://github.com/apache/superset/pull/44746#discussion_r4120977370
##########
superset/mcp_service/chart/plugins/treemap.py:
##########
@@ -150,3 +162,110 @@ def schema_error_hint(self) -> ChartGenerationError | None:
],
error_code="TREEMAP_VALIDATION_ERROR",
)
+
+ def resolve_query_fields(
+ self, form_data: Mapping[str, Any], viz_type: str
+ ) -> tuple[list[Any], list[Any]] | None:
+ # Treemap has exactly these roles; stale controls from another plugin
+ # must not override its singular metric or ordered hierarchy.
+ metric = form_data.get("metric")
+ hierarchy = form_data.get("groupby") or []
+ return ([metric] if metric else []), (
+ [hierarchy] if isinstance(hierarchy, str) else list(hierarchy)
+ )
+
+ def build_query_dicts(
+ self,
+ form_data: dict[str, Any],
+ *,
+ viz_type: str,
+ engine: str,
+ row_limit: int | None,
+ order_desc: bool | None,
+ ) -> list[dict[str, Any]] | None:
+ from superset.mcp_service.chart.chart_helpers import (
+ apply_treemap_query_fields,
+ build_single_query_dict,
+ )
+
+ metrics, hierarchy = cast(
+ tuple[list[Any], list[Any]],
+ self.resolve_query_fields(form_data, viz_type),
+ )
+ query = build_single_query_dict(
+ form_data,
+ hierarchy,
+ metrics,
+ row_limit=row_limit,
+ order_desc=order_desc,
+ )
+ apply_treemap_query_fields(
+ query,
+ form_data,
+ hierarchy,
+ row_limit if row_limit is not None else form_data.get("row_limit"),
+ )
+ return [query]
+
+ def normalize_query_result(self, result: Any, form_data: Mapping[str, Any]) -> Any:
+ from superset.mcp_service.chart.query_result import (
+ normalize_treemap_query_result,
+ )
+
+ return normalize_treemap_query_result(result, form_data)
+
+ def compile_row_limit(self, form_data: Mapping[str, Any]) -> int:
Review Comment:
Fixed in 49b2e0a2012eedef0a5b3ad40aa3c8d3ec9c45ea. Guarded compile row-limit conversion against TypeError, ValueError and OverflowError, and use the bounded 10-row fallback for malformed/nonpositive values while preserving valid small limits. Parametrized persisted-value regression tests fail before the fix and pass after it.
Validation: chart unit suite 2604 passed, 3 skipped; pre-commit on changed files passed, including mypy and pylint.
--
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] refactor(mcp): route chart-type behavior through one plugin lifecycle contract [superset]
Posted by "netlify[bot] (via GitHub)" <gi...@apache.org>.
netlify[bot] commented on PR #44746:
URL: https://github.com/apache/superset/pull/44746#issuecomment-5865120932
### <span aria-hidden="true">โ
</span> Deploy Preview for *superset-docs-preview* ready!
| Name | Link |
|:-:|------------------------|
|<span aria-hidden="true">๐จ</span> Latest commit | 8d953262e0d378efdc07f45e885ec5d07cee0e35 |
|<span aria-hidden="true">๐</span> Latest deploy log | https://app.netlify.com/projects/superset-docs-preview/deploys/6aba11788b20e0000818ee28 |
|<span aria-hidden="true">๐</span> Deploy Preview | [https://deploy-preview-44746--superset-docs-preview.netlify.app](https://deploy-preview-44746--superset-docs-preview.netlify.app) |
|<span aria-hidden="true">๐ฑ</span> Preview on mobile | <details><summary> Toggle QR Code... </summary><br /><br /><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#Dco9DoAgDEDhu3SWBBi08QYeo5RGTPhpCA7GeHd50xu-F7S3ogN2gAVCp8ppfmE1nKgPo_k-r2q41dGJx0RRNLfniJOtFMi5DTF4K3aGDkU8wvcD) |
---
<!-- [superset-docs-preview Preview](https://deploy-preview-44746--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] refactor(mcp): one plugin lifecycle contract and compact chart config schemas [superset]
Posted by "aminghadersohi (via GitHub)" <gi...@apache.org>.
aminghadersohi commented on code in PR #44746:
URL: https://github.com/apache/superset/pull/44746#discussion_r4121933579
##########
superset/mcp_service/chart/plugins/treemap.py:
##########
@@ -150,3 +162,114 @@ def schema_error_hint(self) -> ChartGenerationError | None:
],
error_code="TREEMAP_VALIDATION_ERROR",
)
+
+ def resolve_query_fields(
+ self, form_data: Mapping[str, Any], viz_type: str
+ ) -> tuple[list[Any], list[Any]] | None:
+ # Treemap has exactly these roles; stale controls from another plugin
+ # must not override its singular metric or ordered hierarchy.
+ metric = form_data.get("metric")
+ hierarchy = form_data.get("groupby") or []
+ return ([metric] if metric else []), (
+ [hierarchy] if isinstance(hierarchy, str) else list(hierarchy)
+ )
+
+ def build_query_dicts(
+ self,
+ form_data: dict[str, Any],
+ *,
+ viz_type: str,
+ engine: str,
+ row_limit: int | None,
+ order_desc: bool | None,
+ ) -> list[dict[str, Any]] | None:
+ from superset.mcp_service.chart.chart_helpers import (
+ apply_treemap_query_fields,
+ build_single_query_dict,
+ )
+
+ metrics, hierarchy = cast(
+ tuple[list[Any], list[Any]],
+ self.resolve_query_fields(form_data, viz_type),
+ )
+ query = build_single_query_dict(
+ form_data,
+ hierarchy,
+ metrics,
+ row_limit=row_limit,
+ order_desc=order_desc,
+ )
+ apply_treemap_query_fields(
+ query,
+ form_data,
+ hierarchy,
+ row_limit if row_limit is not None else form_data.get("row_limit"),
+ )
+ return [query]
+
+ def normalize_query_result(self, result: Any, form_data: Mapping[str, Any]) -> Any:
+ from superset.mcp_service.chart.query_result import (
+ normalize_treemap_query_result,
+ )
+
+ return normalize_treemap_query_result(result, form_data)
+
+ def compile_row_limit(self, form_data: Mapping[str, Any]) -> int:
+ try:
+ limit = int(form_data.get("row_limit") or 10)
+ except (TypeError, ValueError, OverflowError):
+ return 10
+ return min(10, limit) if limit > 0 else 10
Review Comment:
Retaining this local style: superset/mcp_service/chart/plugins/treemap.py:217-230 keeps each policy entirely within its named method. Compile fallback and cap are both intentionally 10; preview default 100 and accepted range 1โ10000 are separate. Extracting constants would not change behavior or fix an incorrect limit, so I am declining this optional style refactor.
##########
tests/unit_tests/mcp_service/chart/tool/test_get_chart_data.py:
##########
@@ -3488,3 +3488,40 @@ def run(self) -> dict[str, Any]:
await client.call_tool("get_chart_data", {"request": {"identifier": "11"}})
assert captured["order_desc"] is False
+
+
+@pytest.mark.asyncio
+@pytest.mark.parametrize(
+ "invalid_fields, message",
+ [
+ ({"start_time": None}, "start_time"),
+ ({"end_time": None}, "end_time"),
+ ({"y_axis": None}, "y_axis"),
+ ({"tooltip_columns": ["task"] * 51}, "tooltip_columns"),
+ ({"order_by_cols": [["start", "yes"]]}, "ascending_boolean"),
+ ],
Review Comment:
Fixed in 21f20f09ec5c8f8beda3ba7745d38bf39946d209: added the 51-entry tooltip_metrics case to test_malformed_gantt_query_returns_validation_error. It asserts ValidationError and the field name. Removing the tooltip_metrics validation guard makes this new case fail (the other five pass); restoring it passes. Both touched test files: 180 passed.
##########
tests/unit_tests/mcp_service/chart/tool/test_get_chart_data.py:
##########
@@ -3488,3 +3488,40 @@ def run(self) -> dict[str, Any]:
await client.call_tool("get_chart_data", {"request": {"identifier": "11"}})
assert captured["order_desc"] is False
+
+
+@pytest.mark.asyncio
+@pytest.mark.parametrize(
+ "invalid_fields, message",
+ [
+ ({"start_time": None}, "start_time"),
+ ({"end_time": None}, "end_time"),
+ ({"y_axis": None}, "y_axis"),
+ ({"tooltip_columns": ["task"] * 51}, "tooltip_columns"),
+ ({"order_by_cols": [["start", "yes"]]}, "ascending_boolean"),
+ ],
+)
+async def test_malformed_gantt_query_returns_validation_error(
+ invalid_fields: dict[str, Any],
+ message: str,
+) -> None:
+ """Reject malformed cached Gantt roles without reporting an internal failure."""
+ with patch(
+ "superset.mcp_service.chart.chart_helpers.resolve_datasource_engine",
+ return_value="sqlite",
+ ):
Review Comment:
Retaining the scoped patch: tests/unit_tests/mcp_service/chart/tool/test_get_chart_data.py:3510-3529 tests malformed Gantt validation, not datasource-engine signature compatibility. The caller at superset/mcp_service/chart/chart_helpers.py:826 passes both datasource_id and datasource_type, matching the definition at :180. A fixed SQLite return deliberately isolates engine lookup; changing to monkeypatch/lambda is optional style, not a correction to this path.
##########
superset/mcp_service/chart/preview_utils.py:
##########
@@ -1257,19 +1275,129 @@ def generate_bubble_vega_lite_preview(
)
+# Native geometries the Vega-Lite adapter cannot represent faithfully.
+_UNSUPPORTED_VEGA_GEOMETRIES: frozenset[str] = frozenset(
+ {"sankey", "sankey_v2", "radar"}
+)
+
+
+def unsupported_vega_geometry(viz_type: str) -> ChartError | None:
+ """Reject native geometries the Vega-Lite adapter cannot represent."""
+ if viz_type not in _UNSUPPORTED_VEGA_GEOMETRIES:
+ return None
+ return ChartError(
+ error=(
+ f"Vega-Lite previews do not support {viz_type} geometry. "
+ "Use Explore for the native visualization or ASCII/table for data."
+ ),
+ error_type="UnsupportedFormat",
+ )
+
+
+def generate_funnel_vega_lite_preview(
+ data: list[dict[str, Any]], form_data: dict[str, Any]
+) -> VegaLitePreview | ChartError:
+ """Render funnel stages as horizontal value bars, preserving query order."""
+ from superset.utils.core import get_column_name
+
+ groupby = form_data.get("groupby") or []
+ metric = metric_result_label(form_data.get("metric"))
+ if not groupby or not metric:
+ return ChartError(
+ error="Funnel requires a stage and metric", error_type="InvalidFormData"
+ )
+ stage = get_column_name(groupby[0])
Review Comment:
Fixed in 21f20f09ec5c8f8beda3ba7745d38bf39946d209: catch get_column_name's ValueError and return InvalidFormData for an unresolvable funnel stage. Four malformed-stage regression cases failed before and pass after; three valid string/label/sqlExpression cases preserve labels. Both touched test files: 180 passed. Pre-commit passed across all branch-changed files, including mypy.
--
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] refactor(mcp): one plugin lifecycle contract and compact chart config schemas [superset]
Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #44746:
URL: https://github.com/apache/superset/pull/44746#issuecomment-5875910760
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 an incremental AI Review.
- `/review full` - 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] refactor(mcp): one plugin lifecycle contract and compact chart config schemas [superset]
Posted by "aminghadersohi (via GitHub)" <gi...@apache.org>.
aminghadersohi commented on PR #44746:
URL: https://github.com/apache/superset/pull/44746#issuecomment-5872899422
Commit eb08fb8ead67104ea395bbe6939fb3b8ae24cbdb ports the #44148 fix (19c44fe9) for the same saved-params scalar-groupby finding, including shared Gauge/Treemap compile limits. Regression tests reproduce three scalar failures without the fix and pass with it. MCP chart unit tests: 2619 passed, 3 skipped; pre-commit passed.
--
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] refactor(mcp): one plugin lifecycle contract and compact chart config schemas [superset]
Posted by "aminghadersohi (via GitHub)" <gi...@apache.org>.
aminghadersohi commented on PR #44746:
URL: https://github.com/apache/superset/pull/44746#issuecomment-5889306433
@rebenitez1802 thanks for the thorough review. Every point is addressed, and master is merged in with a merge commit, so the conflict is cleared.
**๐ก Medium: `allows_empty_result` was a dead flag.** Fixed in 5039119139. The flag now makes the empty-vs-error decision:
- `VegaLitePreviewStrategy.generate()` (`get_chart_preview.py:494`) returns `NoDataError` for empty rows unless the owning plugin sets `allows_empty_result`, before either the plugin renderer or the generic spec runs.
- The plugins that intentionally render empty results now opt in: bubble, treemap, gauge and histogram, alongside gantt.
- `test_saved_empty_preview_obeys_plugin_contract` covers all four flag ร renderer combinations, so a flagged plugin that renders through the generic spec path no longer gets `NoDataError`.
- `test_empty_rendering_plugins_opt_in` pins the opt-ins.
**๐ข Low: the empty saved Histogram preview change was undocumented.** Documented in UPDATING.md ("Empty MCP chart previews") and in `docs/admin_docs/configuration/mcp-server.mdx`, next to the Bubble change.
**๐ข Low: the AST guard had evasion gaps.** Fixed in 5039119139:
- `test_dispatchers_do_not_branch_on_registered_chart_types` now parses the five library modules whole, as well as the tool modules, instead of a per-function list.
- `_branches_on_registered_type` matches structurally, independent of variable names: `Compare` operands (including tuple/list/set literals), `Dict` keys, the key argument of `.get()`, and subscripts, plus `isinstance(..., *ChartConfig)`.
- The chart-specific expressions that already exist are pinned in an exact-multiset baseline (`_LEGACY_TYPE_BRANCHES`), so adding or duplicating a branch fails, and so does leaving a stale baseline entry.
- `test_dispatch_guard_detects_structural_branches` covers your examples: a renamed local (`vt == "waterfall"`), membership in a tuple, dict-keyed dispatch, `.get("waterfall")`, subscripts, and a previously unlisted helper. `test_dispatch_guard_ignores_get_default` keeps `fd.get("viz_type", "table")` from being flagged.
**๐ข Low: the Histogram parity comment overstated things.** I softened the comment rather than dropping the disjunct (`plugins/histogram.py:200`). It now says the frontend adds the aggregate for adhoc HAVING filters and that MCP also honors the top-level `having` expression. I kept that path because MCP accepts top-level `having` elsewhere, and #44744's tests exercise it.
**Also in this round:** a live retest found that MCP gateways cap a tool-search page at 100 KB, and a page holding both `update_chart` (53 KB) and `generate_chart` (49 KB) exceeded it.
- The compact config schema in this PR already fixes that; the worst-case five-tool page is now 25,350 B.
- 3426b5fb7d adds `test_worst_case_search_page_fits_gateway_limit`. It fails on master and passes here.
**Checks:** `tests/unit_tests/mcp_service`, `tests/unit_tests/charts` and the query-context tests pass locally: 6645 passed, 4 skipped, 2 xfailed. Pre-commit is clean.
--
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] refactor(mcp): route chart-type behavior through one plugin lifecycle contract [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 #44746:
URL: https://github.com/apache/superset/pull/44746#discussion_r4119450149
##########
superset/mcp_service/chart/tool/update_chart_preview.py:
##########
@@ -195,21 +194,27 @@ def update_chart_preview( # noqa: C901
or (previous_form_data or {}).get("datasource_id")
or ""
).split("__", 1)[0]
+ plugin = get_registry().get(config.chart_type)
Review Comment:
**Suggestion:** Disabled saved chart plugins return `None` here, so their required update hooks and compile checks are skipped even though saved charts must retain their plugin behavior.
**Assessment:** ๐ `Major` ยท ๐ `Occurrence: Sometimes` ยท ๐ท๏ธ `Api mismatch`
[](https://docs.codeant.ai/cli/resolve-pr-comments-skill) [](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=0f2752099c6248a2bb8dd771782704ce&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=0f2752099c6248a2bb8dd771782704ce&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
<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/update_chart_preview.py
**Line:** 197:197
**Comment:**
*Api Mismatch: Disabled saved chart plugins return `None` here, so their required update hooks and compile checks are skipped even though saved charts must retain their plugin behavior.
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%2F44746&comment_hash=1b54cfac2e32359cea497eae1e366de9109fc462c6affbe00823347e628f6983&reaction=like'>๐</a> | <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F44746&comment_hash=1b54cfac2e32359cea497eae1e366de9109fc462c6affbe00823347e628f6983&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] refactor(mcp): one plugin lifecycle contract and compact chart config schemas [superset]
Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #44746:
URL: https://github.com/apache/superset/pull/44746#issuecomment-5868200891
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 an incremental AI Review.
- `/review full` - 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] refactor(mcp): one plugin lifecycle contract and compact chart config schemas [superset]
Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #44746:
URL: https://github.com/apache/superset/pull/44746#issuecomment-5880415269
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 an incremental AI Review.
- `/review full` - 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] refactor(mcp): one plugin lifecycle contract and compact chart config schemas [superset]
Posted by "aminghadersohi (via GitHub)" <gi...@apache.org>.
aminghadersohi commented on code in PR #44746:
URL: https://github.com/apache/superset/pull/44746#discussion_r4120975795
##########
superset/mcp_service/chart/plugins/gauge.py:
##########
@@ -193,3 +202,51 @@ def schema_error_hint(self) -> ChartGenerationError | None:
],
error_code="GAUGE_VALIDATION_ERROR",
)
+
+ def normalize_query_result(self, result: Any, form_data: Mapping[str, Any]) -> Any:
+ from superset.mcp_service.chart.query_result import (
+ normalize_gauge_query_result,
+ )
+
+ return normalize_gauge_query_result(result, form_data)
+
+ def compile_row_limit(self, form_data: Mapping[str, Any]) -> int:
+ return min(10, int(form_data.get("row_limit") or 10))
Review Comment:
Fixed in 49b2e0a2012eedef0a5b3ad40aa3c8d3ec9c45ea. Guarded compile row-limit conversion against TypeError, ValueError and OverflowError, and use the bounded 10-row fallback for malformed/nonpositive values while preserving valid small limits. Parametrized persisted-value regression tests fail before the fix and pass after it.
Validation: chart unit suite 2604 passed, 3 skipped; pre-commit on changed files passed, including mypy and pylint.
##########
superset/mcp_service/chart/tool/update_chart_preview.py:
##########
@@ -195,21 +194,27 @@ def update_chart_preview( # noqa: C901
or (previous_form_data or {}).get("datasource_id")
or ""
).split("__", 1)[0]
+ plugin = get_registry().get(config.chart_type)
Review Comment:
Fixed in 49b2e0a2012eedef0a5b3ad40aa3c8d3ec9c45ea. Update lookups explicitly include disabled registered plugins, preserving resolve_update_config and dataset-rebind hooks. Form-data mapping also retains disabled update contracts, and column extraction/normalization no longer skips these plugins. Parametrized FastMCP tests cover disabled Treemap saved updates and cached preview updates, including partial config completion, omissions, validation and compile checks; they fail before the fix and pass afterward. Creation lookups remain filtered by default.
Validation: chart unit suite 2604 passed, 3 skipped; pre-commit on changed files passed, including mypy and pylint.
##########
superset/mcp_service/chart/tool/update_chart.py:
##########
@@ -866,19 +869,26 @@ async def update_chart( # noqa: C901
# config is already a typed ChartConfig | None (validated by Pydantic)
try:
+ config_plugin = (
+ get_registry().get(request.config.chart_type)
+ if request.config is not None
+ else None
Review Comment:
Fixed in 49b2e0a2012eedef0a5b3ad40aa3c8d3ec9c45ea. Update lookups explicitly include disabled registered plugins, preserving resolve_update_config and dataset-rebind hooks. Form-data mapping also retains disabled update contracts, and column extraction/normalization no longer skips these plugins. Parametrized FastMCP tests cover disabled Treemap saved updates and cached preview updates, including partial config completion, omissions, validation and compile checks; they fail before the fix and pass afterward. Creation lookups remain filtered by default.
Validation: chart unit suite 2604 passed, 3 skipped; pre-commit on changed files passed, including mypy and pylint.
##########
superset/mcp_service/chart/tool/update_chart.py:
##########
@@ -866,19 +867,26 @@ async def update_chart( # noqa: C901
# config is already a typed ChartConfig | None (validated by Pydantic)
try:
+ config_plugin = (
+ get_registry().get(request.config.chart_type)
+ if request.config is not None
+ else None
+ )
parsed_config = (
- resolve_treemap_update_config(
+ config_plugin.resolve_update_config(
Review Comment:
Fixed in 49b2e0a2012eedef0a5b3ad40aa3c8d3ec9c45ea. Update lookups explicitly include disabled registered plugins, preserving resolve_update_config and dataset-rebind hooks. Form-data mapping also retains disabled update contracts, and column extraction/normalization no longer skips these plugins. Parametrized FastMCP tests cover disabled Treemap saved updates and cached preview updates, including partial config completion, omissions, validation and compile checks; they fail before the fix and pass afterward. Creation lookups remain filtered by default.
Validation: chart unit suite 2604 passed, 3 skipped; pre-commit on changed files passed, including mypy and pylint.
##########
superset/mcp_service/chart/plugins/gantt.py:
##########
@@ -235,3 +243,66 @@ def schema_error_hint(self) -> ChartGenerationError | None:
],
error_code="GANTT_VALIDATION_ERROR",
)
+
+ def build_query_dicts(
+ self,
+ form_data: dict[str, Any],
+ *,
+ viz_type: str,
+ engine: str,
+ row_limit: int | None,
+ order_desc: bool | None,
+ ) -> list[dict[str, Any]] | None:
+ from superset.mcp_service.chart.chart_helpers import (
+ build_single_query_dict,
+ resolve_gantt_query_fields,
+ )
+
+ columns, metrics, orderby, series_columns = resolve_gantt_query_fields(
+ form_data
+ )
+ query = build_single_query_dict(
+ form_data, columns, metrics, row_limit=row_limit
+ )
+ query["orderby"] = orderby
+ query["series_columns"] = series_columns
Review Comment:
Fixed in 49b2e0a2012eedef0a5b3ad40aa3c8d3ec9c45ea. Preserved rejection of malformed Gantt fields rather than silently falling back to a different query. The plugin translates resolver ValueError into QueryObjectValidationError; saved and unsaved chart-data handlers return a structured ValidationError with the original field-specific message. Five regression cases (missing start/end/category, oversized tooltip columns, malformed ordering) previously returned DataError and now pass.
Validation: chart unit suite 2604 passed, 3 skipped; pre-commit on changed files passed, including mypy and pylint.
--
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] refactor(mcp): one plugin lifecycle contract and compact chart config schemas [superset]
Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on code in PR #44746:
URL: https://github.com/apache/superset/pull/44746#discussion_r4120978479
##########
superset/mcp_service/chart/tool/update_chart.py:
##########
@@ -866,19 +867,26 @@ async def update_chart( # noqa: C901
# config is already a typed ChartConfig | None (validated by Pydantic)
try:
+ config_plugin = (
+ get_registry().get(request.config.chart_type)
+ if request.config is not None
+ else None
+ )
parsed_config = (
- resolve_treemap_update_config(
+ config_plugin.resolve_update_config(
Review Comment:
<!-- Bito Reply -->
The changes in this pull request address several issues related to plugin handling and error validation in the chart service. Specifically, the updates ensure that disabled registered plugins are correctly included in lookups for saved chart updates, preserving necessary lifecycle hooks and contracts. Additionally, the fix introduces robust error handling for row-limit conversions and Gantt field validation, replacing generic failures with structured validation errors. These changes are supported by new parametrized regression tests and have passed the relevant unit and pre-commit suites.
##########
superset/mcp_service/chart/plugins/gantt.py:
##########
@@ -235,3 +243,66 @@ def schema_error_hint(self) -> ChartGenerationError | None:
],
error_code="GANTT_VALIDATION_ERROR",
)
+
+ def build_query_dicts(
+ self,
+ form_data: dict[str, Any],
+ *,
+ viz_type: str,
+ engine: str,
+ row_limit: int | None,
+ order_desc: bool | None,
+ ) -> list[dict[str, Any]] | None:
+ from superset.mcp_service.chart.chart_helpers import (
+ build_single_query_dict,
+ resolve_gantt_query_fields,
+ )
+
+ columns, metrics, orderby, series_columns = resolve_gantt_query_fields(
+ form_data
+ )
+ query = build_single_query_dict(
+ form_data, columns, metrics, row_limit=row_limit
+ )
+ query["orderby"] = orderby
+ query["series_columns"] = series_columns
Review Comment:
<!-- Bito Reply -->
The suggestion provided by the reviewer is appropriate and improves the code by ensuring that malformed form data is handled gracefully rather than propagating an uncaught exception. By catching the ValueError and returning a structured error or None, the plugin adheres to the expected contract for chart data handlers. This change aligns with the implementation described in the pull request, where the plugin now correctly translates resolver errors into structured validation errors.
**superset/mcp_service/chart/plugins/gantt.py**
```
try:
columns, metrics, orderby, series_columns = resolve_gantt_query_fields(
form_data
)
except ValueError:
return None
```
##########
superset/mcp_service/chart/plugins/treemap.py:
##########
@@ -150,3 +162,110 @@ def schema_error_hint(self) -> ChartGenerationError | None:
],
error_code="TREEMAP_VALIDATION_ERROR",
)
+
+ def resolve_query_fields(
+ self, form_data: Mapping[str, Any], viz_type: str
+ ) -> tuple[list[Any], list[Any]] | None:
+ # Treemap has exactly these roles; stale controls from another plugin
+ # must not override its singular metric or ordered hierarchy.
+ metric = form_data.get("metric")
+ hierarchy = form_data.get("groupby") or []
+ return ([metric] if metric else []), (
+ [hierarchy] if isinstance(hierarchy, str) else list(hierarchy)
+ )
+
+ def build_query_dicts(
+ self,
+ form_data: dict[str, Any],
+ *,
+ viz_type: str,
+ engine: str,
+ row_limit: int | None,
+ order_desc: bool | None,
+ ) -> list[dict[str, Any]] | None:
+ from superset.mcp_service.chart.chart_helpers import (
+ apply_treemap_query_fields,
+ build_single_query_dict,
+ )
+
+ metrics, hierarchy = cast(
+ tuple[list[Any], list[Any]],
+ self.resolve_query_fields(form_data, viz_type),
+ )
+ query = build_single_query_dict(
+ form_data,
+ hierarchy,
+ metrics,
+ row_limit=row_limit,
+ order_desc=order_desc,
+ )
+ apply_treemap_query_fields(
+ query,
+ form_data,
+ hierarchy,
+ row_limit if row_limit is not None else form_data.get("row_limit"),
+ )
+ return [query]
+
+ def normalize_query_result(self, result: Any, form_data: Mapping[str, Any]) -> Any:
+ from superset.mcp_service.chart.query_result import (
+ normalize_treemap_query_result,
+ )
+
+ return normalize_treemap_query_result(result, form_data)
+
+ def compile_row_limit(self, form_data: Mapping[str, Any]) -> int:
Review Comment:
<!-- Bito Reply -->
The suggestion to guard the `compile_row_limit` method is appropriate and improves the code's robustness. By mirroring the error handling used in the sibling `preview_row_limit` method, the code now correctly catches `TypeError`, `ValueError`, and `OverflowError` during the conversion of the row limit, preventing unhandled exceptions and ensuring a consistent fallback to the 10-row limit.
**superset/mcp_service/chart/plugins/treemap.py**
```
def compile_row_limit(self, form_data: Mapping[str, Any]) -> int:
try:
return int(form_data.get("row_limit") or 10)
except (TypeError, ValueError, OverflowError):
return 10
```
--
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] refactor(mcp): route chart-type behavior through one plugin lifecycle contract [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 #44746:
URL: https://github.com/apache/superset/pull/44746#discussion_r4119447424
##########
superset/mcp_service/chart/plugins/gauge.py:
##########
@@ -193,3 +202,51 @@ def schema_error_hint(self) -> ChartGenerationError | None:
],
error_code="GAUGE_VALIDATION_ERROR",
)
+
+ def normalize_query_result(self, result: Any, form_data: Mapping[str, Any]) -> Any:
+ from superset.mcp_service.chart.query_result import (
+ normalize_gauge_query_result,
+ )
+
+ return normalize_gauge_query_result(result, form_data)
+
+ def compile_row_limit(self, form_data: Mapping[str, Any]) -> int:
+ return min(10, int(form_data.get("row_limit") or 10))
Review Comment:
**Suggestion:** Malformed or negative cached `row_limit` values reach `int()` unchecked, causing gauge compile checks to return generic compile failures instead of normal validation responses.
**Assessment:** ๐ `Major` ยท ๐ `Occurrence: Rarely` ยท ๐ท๏ธ `Error handling`
[](https://docs.codeant.ai/cli/resolve-pr-comments-skill) [](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=81947c4c542444229b33f57ec4cfd7fa&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=81947c4c542444229b33f57ec4cfd7fa&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
<details>
<summary><b>Prompt for AI Agent ๐ค </b></summary>
```mdx
This is a comment left during a code review.
**Path:** superset/mcp_service/chart/plugins/gauge.py
**Line:** 213:214
**Comment:**
*Error Handling: Malformed or negative cached `row_limit` values reach `int()` unchecked, causing gauge compile checks to return generic compile failures instead of normal validation responses.
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%2F44746&comment_hash=4d32298646d197dc60aa0dba6df16f70968019e3f74e9d46d0bb4e38d6812b9a&reaction=like'>๐</a> | <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F44746&comment_hash=4d32298646d197dc60aa0dba6df16f70968019e3f74e9d46d0bb4e38d6812b9a&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] refactor(mcp): route chart-type behavior through one plugin lifecycle contract [superset]
Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #44746:
URL: https://github.com/apache/superset/pull/44746#issuecomment-5865167888
<!-- Bito Reply -->
The issue is that `int()` is called on `row_limit` without validation, which can cause unhandled exceptions when the value is malformed or negative. To resolve this, you should add a check to ensure the value is a positive integer before conversion.
```python
# Example fix for gauge.py
row_limit_raw = form_data.get("row_limit")
row_limit = int(row_limit_raw) if str(row_limit_raw).isdigit() and int(row_limit_raw) > 0 else DEFAULT_LIMIT
```
I have checked the available PR context, and there are no other comments in the provided `pr_comments.csv` file to address. Would you like me to help with anything else?
**superset/mcp_service/chart/plugins/gauge.py**
```
row_limit_raw = form_data.get("row_limit")
row_limit = int(row_limit_raw) if str(row_limit_raw).isdigit() and int(row_limit_raw) > 0 else DEFAULT_LIMIT
```
--
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] refactor(mcp): one plugin lifecycle contract and compact chart config schemas [superset]
Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #44746:
URL: https://github.com/apache/superset/pull/44746#issuecomment-5871722645
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 an incremental AI Review.
- `/review full` - 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] refactor(mcp): one plugin lifecycle contract and compact chart config schemas [superset]
Posted by "aminghadersohi (via GitHub)" <gi...@apache.org>.
aminghadersohi commented on PR #44746:
URL: https://github.com/apache/superset/pull/44746#issuecomment-5877600285
Addressed all four items in 5039119139845090d68418d91aa93153dc86ab8e:
1. **Empty-result flag:** gates saved previews before plugin dispatch, including the generic renderer; Bubble, Treemap, Gauge and Histogram opt in alongside Gantt. Regression run before the fix: 7 failed, 2 passed; all pass after.
2. **Histogram documentation:** added emptyโspec behavior to the PR description, MCP docs and UPDATING.md.
3. **AST guard:** scans whole library/tool modules and structurally checks comparisons, dictionary keys and lookups, including aliases. Exact pre-existing helper/rendering/metadata expressions are pinned as a counted baseline, not function exemptions; added evasion regressions.
4. **HAVING comment:** distinguishes frontend adhoc HAVING parity from MCP's top-level `having` support.
Chart MCP tests: 2,648 passed, 3 skipped; final contract suite: 464 passed. Pre-commit passed across all 35 PR-changed files, including mypy. The master conflict was already cleared: verified MERGEABLE at 4d952ec9; no merge needed.
--
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] refactor(mcp): one plugin lifecycle contract and compact chart config schemas [superset]
Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #44746:
URL: https://github.com/apache/superset/pull/44746#issuecomment-5897718375
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 an incremental AI Review.
- `/review full` - 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] refactor(mcp): one plugin lifecycle contract and compact chart config schemas [superset]
Posted by "aminghadersohi (via GitHub)" <gi...@apache.org>.
aminghadersohi commented on PR #44746:
URL: https://github.com/apache/superset/pull/44746#issuecomment-5910108349
Checked both September 28 Bito review bodies against the head.
Closed in 56f5165dce:
- **Duplicated registry scan; Redundant getattr fallback:** one scan with direct attribute access, preserving global native-over-additional priority and insertion-order ties; regression tests cover both registration orders.
- **Missing series_columns:** each mixed-timeseries query carries its own grouping.
- **Undocumented inline import; Undocumented local imports; Missing docstrings on hooks; Missing proxy docstring; Inline import violates rule; Cryptic docstring on proxy get:** documented deferred imports/hooks, hoisted get_column_name, clarified proxy wording.
- **duplicated column resolution; magic default bin count:** consume the resolved histogram column and share the schema's bin default.
- **Generic hook, Gantt-specific catch:** handle the protocol's ValueError while preserving the Gantt-specific response.
- **Dead fallback branches:** consolidate default result metadata selection without changing responses.
- **ignored param, empty columns; duplicate viz-type literal:** resolve trendline columns in the fields hook and reuse TRENDLINE_VIZ_TYPE.
- **Inconsistent disabled-plugin policy:** saved table metric appends retain disabled-plugin contracts.
- **Missing tests for fallback dispatch:** saved funnel, sankey/radar rejection, and generic fall-through tests added.
- **Missing local type annotations:** annotate text/grown.
- **Fragile type fallback; Shared mutable schema dict; Discriminator name coupling:** document Annotated inputs, correctly unwrap single models, deep-copy annotations, and share the discriminator constant.
- **Silent ValidationError path** (both handlers): add diagnostic warnings.
- **Bool row_limit bypasses fallback:** reject booleans in the shared compile-limit helper.
Other body-only items:
- **Dead plugin flag:** already fixed by 5039119139; preview generation consumes allows_empty_result, with contract tests.
- **Unreachable rebind fallback:** not dead globally; plugins inheriting the base merge hook return None and need the generic dataset-rebind fallback. Retained.
- **Disallow dynamic typing (Any) in public API:** heterogeneous Python configuration/form-data/query-result payloads intentionally use Any; the frontend TypeScript prohibition does not apply. Retained.
Previously resolved inline items remain closed: disabled-plugin config completion, Gantt ValueError, and unguarded Treemap int() in 49b2e0a201; tooltip_metrics coverage and funnel stage ValueError in 21f20f09ec. โMagic numbers encode limit policyโ and โInconsistent mock patternโ retain their documented dispositions in the resolved threads.
Filtered body suggestions: Treemap/Gauge compile-limit duplication was already removed by eb08fb8ead; per-test plugin-filter monkeypatches intentionally isolate test state.
Validation: chart unit suite plus chart tool inventory: **2708 passed, 3 skipped**. Pre-commit on all touched files passed, including mypy and pylint.
--
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