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/04/17 14:42:44 UTC
[PR] chore(mcp): extract shared chart helpers and ASCII rendering into separate modules [superset]
aminghadersohi opened a new pull request, #39438:
URL: https://github.com/apache/superset/pull/39438
### SUMMARY
Refactors MCP service chart tools to reduce code duplication and improve modularity:
- **Extract 3 shared utilities into `chart_helpers.py`**: `find_chart_by_identifier`, `get_cached_form_data`, `extract_form_data_key_from_url` — previously duplicated across 7+ tool files
- **Extract ASCII chart rendering into `ascii_charts.py`**: ~866 lines of pure rendering functions moved out of `get_chart_preview.py` (2283→1416 lines), with type hints modernized to Python 3.10+ style
- **Replace broad `except Exception` with specific exceptions** in 4 chart tools — `GlobalErrorHandlerMiddleware` already catches truly unexpected errors
- **Fix fragile `str.split("form_data_key=")` URL parsing** in `update_chart_preview.py` — replaced with proper `urlparse`/`parse_qs`
All changes are behavioral no-ops — tools produce identical responses. Verified against live local MCP server.
### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
N/A — no UI changes, pure backend refactoring.
### TESTING INSTRUCTIONS
1. Start the MCP service locally
2. Verify chart tools work:
- `list_charts` — pagination, filtering
- `get_chart_info` — by ID (exercises `get_cached_form_data` path)
- `get_chart_data` — by ID (exercises `find_chart_by_identifier`)
- `get_chart_preview` with `format: "ascii"` — exercises extracted `ascii_charts.py`
- `generate_explore_link` — exercises `extract_form_data_key_from_url`
- `update_chart_preview` — exercises fixed URL parsing
3. Run unit tests: `python -m pytest tests/unit_tests/mcp_service/chart/ -v`
### ADDITIONAL INFORMATION
- [ ] Has associated issue:
- [ ] Required feature flags:
- [ ] Changes UI
- [ ] Includes DB Migration
- [ ] Introduces new feature or API
- [ ] Removes existing feature or API
--
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] chore(mcp): extract shared chart helpers and ASCII rendering into separate modules [superset]
Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on code in PR #39438:
URL: https://github.com/apache/superset/pull/39438#discussion_r3119157475
##########
superset/mcp_service/chart/tool/get_chart_preview.py:
##########
@@ -1921,25 +1058,12 @@ def __init__(self, fd: Dict[str, Any]):
error_type="NotFound",
)
- elif isinstance(request.identifier, int) or (
- isinstance(request.identifier, str) and request.identifier.isdigit()
- ):
- chart_id = (
- int(request.identifier)
- if isinstance(request.identifier, str)
- else request.identifier
- )
- await ctx.debug(
- "Performing ID-based chart lookup: chart_id=%s" % (chart_id,)
- )
- chart = ChartDAO.find_by_id(chart_id)
- elif isinstance(request.identifier, str):
+ else:
await ctx.debug(
- "Performing UUID-based chart lookup: uuid=%s"
- % (request.identifier,)
+ "Looking up chart: identifier=%s" % (request.identifier,)
)
- # Try UUID lookup using DAO flexible method
- chart = ChartDAO.find_by_id(request.identifier, id_column="uuid")
+ assert request.identifier is not None # validated earlier
+ chart = find_chart_by_identifier(request.identifier)
Review Comment:
<div>
<div id="suggestion">
<div id="issue"><b>Assert statement used for validation</b></div>
<div id="fix">
Replace `assert` with explicit validation and error handling. Assertions can be disabled at runtime with Python's `-O` flag, making them unreliable for production code.
</div>
<details>
<summary>
<b>Code suggestion</b>
</summary>
<blockquote>Check the AI-generated fix before applying</blockquote>
<div id="code">
````suggestion
if request.identifier is None:
raise ValueError("Chart identifier cannot be None")
chart = find_chart_by_identifier(request.identifier)
````
</div>
</details>
</div>
<small><i>Code Review Run #d524a0</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/tool/get_chart_data.py:
##########
@@ -166,25 +154,9 @@ async def get_chart_data( # noqa: C901
# Find the chart by identifier
with event_logger.log_context(action="mcp.get_chart_data.chart_lookup"):
- if isinstance(request.identifier, int) or (
- isinstance(request.identifier, str) and request.identifier.isdigit()
- ):
- chart_id = (
- int(request.identifier)
- if isinstance(request.identifier, str)
- else request.identifier
- )
- await ctx.debug(
- "Performing ID-based chart lookup: chart_id=%s" % (chart_id,)
- )
- chart = ChartDAO.find_by_id(chart_id)
- elif isinstance(request.identifier, str):
- await ctx.debug(
- "Performing UUID-based chart lookup: uuid=%s"
- % (request.identifier,)
- )
- # Try UUID lookup using DAO flexible method
- chart = ChartDAO.find_by_id(request.identifier, id_column="uuid")
+ await ctx.debug("Looking up chart: identifier=%s" % (request.identifier,))
+ assert request.identifier is not None # validated earlier
+ chart = find_chart_by_identifier(request.identifier)
Review Comment:
<div>
<div id="suggestion">
<div id="issue"><b>Replace assert with proper validation check</b></div>
<div id="fix">
Replace `assert` statement with explicit validation and error handling. Assertions can be disabled at runtime and should not be used for input validation.
</div>
<details>
<summary>
<b>Code suggestion</b>
</summary>
<blockquote>Check the AI-generated fix before applying</blockquote>
<div id="code">
````suggestion
with event_logger.log_context(action="mcp.get_chart_data.chart_lookup"):
await ctx.debug("Looking up chart: identifier=%s" % (request.identifier,))
if request.identifier is None:
await ctx.error("Chart identifier is required but was not provided")
return ChartError(
error="Chart identifier is required",
error_type="InvalidRequest",
)
chart = find_chart_by_identifier(request.identifier)
````
</div>
</details>
</div>
<small><i>Code Review Run #d524a0</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] chore(mcp): extract shared chart helpers and ASCII rendering into separate modules [superset]
Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #39438:
URL: https://github.com/apache/superset/pull/39438#issuecomment-4269005191
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] chore(mcp): extract shared chart helpers and ASCII rendering into separate modules [superset]
Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #39438:
URL: https://github.com/apache/superset/pull/39438#issuecomment-4290329366
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 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] chore(mcp): extract shared chart helpers and ASCII rendering into separate modules [superset]
Posted by "aminghadersohi (via GitHub)" <gi...@apache.org>.
aminghadersohi merged PR #39438:
URL: https://github.com/apache/superset/pull/39438
--
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] chore(mcp): extract shared chart helpers and ASCII rendering into separate modules [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 #39438:
URL: https://github.com/apache/superset/pull/39438#discussion_r3119784383
##########
superset/mcp_service/chart/tool/update_chart_preview.py:
##########
@@ -123,9 +126,7 @@ def update_chart_preview(
explore_url = generate_explore_link(request.dataset_id, new_form_data)
# Extract new form_data_key from the explore URL
- new_form_data_key = None
- if "form_data_key=" in explore_url:
- new_form_data_key = explore_url.split("form_data_key=")[1].split("&")[0]
+ new_form_data_key = extract_form_data_key_from_url(explore_url)
Review Comment:
**Suggestion:** The updated URL parser can return `None` when the generated explore URL does not contain `form_data_key` (for fallback URLs), but the function still returns `success=True`. This silently returns an unusable preview state and breaks follow-up update flows that require a valid key. Validate the extracted key and fail the request when it is missing. [logic error]
<details>
<summary><b>Severity Level:</b> Major ⚠️</summary>
```mdx
- ❌ update_chart_preview may return success with null form_data_key.
- ⚠️ Iterative unsaved preview flows cannot continue without key.
```
</details>
```suggestion
if not new_form_data_key:
raise ValueError("Generated explore URL is missing form_data_key")
```
<details>
<summary><b>Steps of Reproduction ✅ </b></summary>
```mdx
1. Call the `update_chart_preview` MCP tool (exported from
`superset/mcp_service/chart/tool/__init__.py:25-32` and implemented in
`superset/mcp_service/chart/tool/update_chart_preview.py:87-181`) with a
`UpdateChartPreviewRequest` whose `dataset_id` refers to a non‑existent or deleted dataset
ID.
2. Inside `update_chart_preview`, the code calls
`generate_explore_link(request.dataset_id, new_form_data)` at
`superset/mcp_service/chart/tool/update_chart_preview.py:125-126`, which invokes
`generate_explore_link()` in `superset/mcp_service/chart/chart_utils.py:157-231`.
3. In `generate_explore_link`, `DatasetDAO.find_by_id(...)` fails to resolve a dataset, so
the condition `if not dataset or numeric_dataset_id is None` at `chart_utils.py:188-192`
or the exception handler at `chart_utils.py:215-231` returns a fallback URL like
`"{base_url}/explore/?datasource_type=table&datasource_id={dataset_id}"` that does not
include any `form_data_key` query parameter.
4. Back in `update_chart_preview`, `extract_form_data_key_from_url(explore_url)` is
executed at `superset/mcp_service/chart/tool/update_chart_preview.py:129`; the helper
`extract_form_data_key_from_url` in `superset/mcp_service/chart/chart_helpers.py:72-81`
parses the URL, finds no `form_data_key` entry, and returns `None`.
5. `update_chart_preview` then builds a response with `"form_data_key": new_form_data_key`
where `new_form_data_key` is `None` and `"success": True` at
`superset/mcp_service/chart/tool/update_chart_preview.py:157-181`, despite the docstring
at `update_chart_preview.py:90-103` promising "Original form_data_key is invalidated, new
one returned."
6. A client following the documented unsaved‑state flows (e.g., calling `get_chart_info` /
`get_chart_data` with `form_data_key` as described in
`superset/mcp_service/chart/schemas.py:125-163` and `1438-1476`) receives a "successful"
preview update but no usable `form_data_key`, so subsequent calls that require a valid
cache key cannot proceed, breaking iterative preview/update flows when the fallback URL
path is taken.
```
</details>
[Fix in Cursor](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt=This%20is%20a%20comment%20left%20during%20a%20code%20review.%0A%0A%2A%2APath%3A%2A%2A%20superset%2Fmcp_service%2Fchart%2Ftool%2Fupdate_chart_preview.py%0A%2A%2ALine%3A%2A%2A%20130%3A130%0A%2A%2AComment%3A%2A%2A%0A%09%2ALogic%20Error%3A%20The%20updated%20URL%20parser%20can%20return%20%60None%60%20when%20the%20generated%20explore%20URL%20does%20not%20contain%20%60form_data_key%60%20%28for%20fallback%20URLs%29%2C%20but%20the%20function%20still%20returns%20%60success%3DTrue%60.%20This%20silently%20returns%20an%20unusable%20preview%20state%20and%20breaks%20follow-up%20update%20flows%20that%20require%20a%20valid%20key.%20Validate%20the%20extracted%20key%20and%20fail%20the%20request%20when%20it%20is%20missing.%0A%0AValidate%20the%20correctness%20of%20the%20flagged%20issue.%20If%20correct%2C%20How%20can%20I%20resolve%20this%3F%20If%20you%20propose%20a%20fix%2C%20implement%20it%20and%20please%20make%20it%20concise.%0AOnce
%20fix%20is%20implemented%2C%20also%20check%20other%20comments%20on%20the%20same%20PR%2C%20and%20ask%20user%20if%20the%20user%20wants%20to%20fix%20the%20rest%20of%20the%20comments%20as%20well.%20if%20said%20yes%2C%20then%20fetch%20all%20the%20comments%20validate%20the%20correctness%20and%20implement%20a%20minimal%20fix%0A) | [Fix in VSCode Claude](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt=This%20is%20a%20comment%20left%20during%20a%20code%20review.%0A%0A%2A%2APath%3A%2A%2A%20superset%2Fmcp_service%2Fchart%2Ftool%2Fupdate_chart_preview.py%0A%2A%2ALine%3A%2A%2A%20130%3A130%0A%2A%2AComment%3A%2A%2A%0A%09%2ALogic%20Error%3A%20The%20updated%20URL%20parser%20can%20return%20%60None%60%20when%20the%20generated%20explore%20URL%20does%20not%20contain%20%60form_data_key%60%20%28for%20fallback%20URLs%29%2C%20but%20the%20function%20still%20returns%20%60success%3DTrue%60.%20This%20silently%20returns%20an%20unusable%20preview%20state%20and%20breaks%20follow-up%20update%20flows%20
that%20require%20a%20valid%20key.%20Validate%20the%20extracted%20key%20and%20fail%20the%20request%20when%20it%20is%20missing.%0A%0AValidate%20the%20correctness%20of%20the%20flagged%20issue.%20If%20correct%2C%20How%20can%20I%20resolve%20this%3F%20If%20you%20propose%20a%20fix%2C%20implement%20it%20and%20please%20make%20it%20concise.%0AOnce%20fix%20is%20implemented%2C%20also%20check%20other%20comments%20on%20the%20same%20PR%2C%20and%20ask%20user%20if%20the%20user%20wants%20to%20fix%20the%20rest%20of%20the%20comments%20as%20well.%20if%20said%20yes%2C%20then%20fetch%20all%20the%20comments%20validate%20the%20correctness%20and%20implement%20a%20minimal%20fix%0A)
*(Use Cmd/Ctrl + Click for best experience)*
<details>
<summary><b>Prompt for AI Agent 🤖 </b></summary>
```mdx
This is a comment left during a code review.
**Path:** superset/mcp_service/chart/tool/update_chart_preview.py
**Line:** 130:130
**Comment:**
*Logic Error: The updated URL parser can return `None` when the generated explore URL does not contain `form_data_key` (for fallback URLs), but the function still returns `success=True`. This silently returns an unusable preview state and breaks follow-up update flows that require a valid key. Validate the extracted key and fail the request when it is missing.
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%2F39438&comment_hash=a217335a6574b7d8a6f82ca5e13cdca1c23f5c51d3ba65547b703992e6043bae&reaction=like'>👍</a> | <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F39438&comment_hash=a217335a6574b7d8a6f82ca5e13cdca1c23f5c51d3ba65547b703992e6043bae&reaction=dislike'>👎</a>
##########
superset/mcp_service/chart/ascii_charts.py:
##########
@@ -0,0 +1,859 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+"""
+ASCII chart rendering functions for MCP chart previews.
+
+Pure rendering functions that take data in and return strings out.
+No dependencies on MCP tools, FastMCP Context, or request objects.
+"""
+
+from __future__ import annotations
+
+import logging
+import math
+from typing import Any
+
+logger = logging.getLogger(__name__)
+
+
+def generate_ascii_chart(
+ data: list[Any], chart_type: str, width: int = 80, height: int = 20
+) -> str:
+ """Generate ASCII art chart from data."""
+ if not data:
+ return "No data available for ASCII chart"
+
+ try:
+ logger.debug(
+ "generate_ascii_chart: chart_type=%s, data_rows=%s", chart_type, len(data)
+ )
+
+ if chart_type in ["bar", "column", "echarts_timeseries_bar"]:
Review Comment:
**Suggestion:** `generate_ascii_chart` does not enforce minimum dimensions before delegating to renderers. Very small `width`/`height` values can produce negative plot sizes and invalid format widths in downstream functions, causing chart generation to fail instead of returning a usable preview. Clamp dimensions to safe minimums before chart-type dispatch. [logic error]
<details>
<summary><b>Severity Level:</b> Major ⚠️</summary>
```mdx
- ❌ ASCII chart previews fail for small custom ascii_width values.
- ⚠️ LLM clients receive generic error text instead of charts.
```
</details>
```suggestion
width = max(width, 21)
height = max(height, 9)
```
<details>
<summary><b>Steps of Reproduction ✅ </b></summary>
```mdx
1. Start the Superset MCP service so the `get_chart_preview` tool defined in
`superset/mcp_service/chart/tool/get_chart_preview.py:18-21` is available.
2. From an MCP client, send a `GetChartPreviewRequest` (schema in
`superset/mcp_service/chart/schemas.py:4-64`) with `format="ascii"`, `ascii_width=10`,
`ascii_height=5`, and an identifier for an existing time-series chart whose `viz_type` is
`"echarts_timeseries_line"`.
3. In `ASCIIPreviewStrategy.generate()` (`get_chart_preview.py:118-207`), after fetching
data via `ChartDataCommand.run()`, the code at `get_chart_preview.py:196-201` calls
`generate_ascii_chart(data, self.chart.viz_type or "table", self.request.ascii_width or
80, self.request.ascii_height or 20)`, passing `width=10` and `height=5` into
`superset/mcp_service/chart/ascii_charts.py:34-56`.
4. Inside `generate_ascii_chart` (`ascii_charts.py:34-56`), the
`"echarts_timeseries_line"` chart type dispatches to `_generate_ascii_line_chart`
(`ascii_charts.py:229-258`), which calls `_create_enhanced_line_chart`
(`ascii_charts.py:292-360`); with `width=10` and `height=5` it computes `chart_width =
min(50, width - 15) = -5` and `chart_height = min(12, height - 8) = -3`, leading to an
empty `grid` and an `IndexError` when writing `grid[y][x]`, which is caught by
`generate_ascii_chart` at `ascii_charts.py:57-59`, causing the function to return the
generic error string `"ASCII chart generation failed"` instead of a usable ASCII preview.
```
</details>
[Fix in Cursor](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt=This%20is%20a%20comment%20left%20during%20a%20code%20review.%0A%0A%2A%2APath%3A%2A%2A%20superset%2Fmcp_service%2Fchart%2Fascii_charts.py%0A%2A%2ALine%3A%2A%2A%2046%3A46%0A%2A%2AComment%3A%2A%2A%0A%09%2ALogic%20Error%3A%20%60generate_ascii_chart%60%20does%20not%20enforce%20minimum%20dimensions%20before%20delegating%20to%20renderers.%20Very%20small%20%60width%60%2F%60height%60%20values%20can%20produce%20negative%20plot%20sizes%20and%20invalid%20format%20widths%20in%20downstream%20functions%2C%20causing%20chart%20generation%20to%20fail%20instead%20of%20returning%20a%20usable%20preview.%20Clamp%20dimensions%20to%20safe%20minimums%20before%20chart-type%20dispatch.%0A%0AValidate%20the%20correctness%20of%20the%20flagged%20issue.%20If%20correct%2C%20How%20can%20I%20resolve%20this%3F%20If%20you%20propose%20a%20fix%2C%20implement%20it%20and%20please%20make%20it%20concise.%0AOnce%20fix%20is%20implemented%2C%20also%20check%2
0other%20comments%20on%20the%20same%20PR%2C%20and%20ask%20user%20if%20the%20user%20wants%20to%20fix%20the%20rest%20of%20the%20comments%20as%20well.%20if%20said%20yes%2C%20then%20fetch%20all%20the%20comments%20validate%20the%20correctness%20and%20implement%20a%20minimal%20fix%0A) | [Fix in VSCode Claude](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt=This%20is%20a%20comment%20left%20during%20a%20code%20review.%0A%0A%2A%2APath%3A%2A%2A%20superset%2Fmcp_service%2Fchart%2Fascii_charts.py%0A%2A%2ALine%3A%2A%2A%2046%3A46%0A%2A%2AComment%3A%2A%2A%0A%09%2ALogic%20Error%3A%20%60generate_ascii_chart%60%20does%20not%20enforce%20minimum%20dimensions%20before%20delegating%20to%20renderers.%20Very%20small%20%60width%60%2F%60height%60%20values%20can%20produce%20negative%20plot%20sizes%20and%20invalid%20format%20widths%20in%20downstream%20functions%2C%20causing%20chart%20generation%20to%20fail%20instead%20of%20returning%20a%20usable%20preview.%20Clamp%20dimensions%20to%20safe%20minimum
s%20before%20chart-type%20dispatch.%0A%0AValidate%20the%20correctness%20of%20the%20flagged%20issue.%20If%20correct%2C%20How%20can%20I%20resolve%20this%3F%20If%20you%20propose%20a%20fix%2C%20implement%20it%20and%20please%20make%20it%20concise.%0AOnce%20fix%20is%20implemented%2C%20also%20check%20other%20comments%20on%20the%20same%20PR%2C%20and%20ask%20user%20if%20the%20user%20wants%20to%20fix%20the%20rest%20of%20the%20comments%20as%20well.%20if%20said%20yes%2C%20then%20fetch%20all%20the%20comments%20validate%20the%20correctness%20and%20implement%20a%20minimal%20fix%0A)
*(Use Cmd/Ctrl + Click for best experience)*
<details>
<summary><b>Prompt for AI Agent 🤖 </b></summary>
```mdx
This is a comment left during a code review.
**Path:** superset/mcp_service/chart/ascii_charts.py
**Line:** 46:46
**Comment:**
*Logic Error: `generate_ascii_chart` does not enforce minimum dimensions before delegating to renderers. Very small `width`/`height` values can produce negative plot sizes and invalid format widths in downstream functions, causing chart generation to fail instead of returning a usable preview. Clamp dimensions to safe minimums before chart-type dispatch.
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%2F39438&comment_hash=c8a998cd4b514f301f565fd98da2f387501ed6c5fb8fd5d91f384218186d4187&reaction=like'>👍</a> | <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F39438&comment_hash=c8a998cd4b514f301f565fd98da2f387501ed6c5fb8fd5d91f384218186d4187&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] chore(mcp): extract shared chart helpers and ASCII rendering into separate modules [superset]
Posted by "netlify[bot] (via GitHub)" <gi...@apache.org>.
netlify[bot] commented on PR #39438:
URL: https://github.com/apache/superset/pull/39438#issuecomment-4291137088
### <span aria-hidden="true">✅</span> Deploy Preview for *superset-docs-preview* ready!
| Name | Link |
|:-:|------------------------|
|<span aria-hidden="true">🔨</span> Latest commit | 4d1548bbe54443e1f69dc1c50f7ed3aa49ef9918 |
|<span aria-hidden="true">🔍</span> Latest deploy log | https://app.netlify.com/projects/superset-docs-preview/deploys/69e7cab5e0c7ce0008d96010 |
|<span aria-hidden="true">😎</span> Deploy Preview | [https://deploy-preview-39438--superset-docs-preview.netlify.app](https://deploy-preview-39438--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> |
---
<!-- [superset-docs-preview Preview](https://deploy-preview-39438--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] chore(mcp): extract shared chart helpers and ASCII rendering into separate modules [superset]
Posted by "codecov[bot] (via GitHub)" <gi...@apache.org>.
codecov[bot] commented on PR #39438:
URL: https://github.com/apache/superset/pull/39438#issuecomment-4269059017
## [Codecov](https://app.codecov.io/gh/apache/superset/pull/39438?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 `9.88593%` with `474 lines` in your changes missing coverage. Please review.
:white_check_mark: Project coverage is 55.45%. Comparing base ([`4bdc8d4`](https://app.codecov.io/gh/apache/superset/commit/4bdc8d4c68102eccc1c3ffeeaa442d896b1f7a31?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`4903845`](https://app.codecov.io/gh/apache/superset/commit/49038454a2580e98f264ed1e12a6733eb8839879?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/39438?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/ascii\_charts.py](https://app.codecov.io/gh/apache/superset/pull/39438?src=pr&el=tree&filepath=superset%2Fmcp_service%2Fchart%2Fascii_charts.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3VwZXJzZXQvbWNwX3NlcnZpY2UvY2hhcnQvYXNjaWlfY2hhcnRzLnB5) | 6.60% | [438 Missing :warning: ](https://app.codecov.io/gh/apache/superset/pull/39438?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\_helpers.py](https://app.codecov.io/gh/apache/superset/pull/39438?src=pr&el=tree&filepath=superset%2Fmcp_service%2Fchart%2Fchart_helpers.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3VwZXJzZXQvbWNwX3NlcnZpY2UvY2hhcnQvY2hhcnRfaGVscGVycy5weQ==) | 29.62% | [19 Missing :warning: ](https://app.codecov.io/gh/apache/superset/pull/39438?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
| [superset/mcp\_service/chart/tool/get\_chart\_data.py](https://app.codecov.io/gh/apache/superset/pull/39438?src=pr&el=tree&filepath=superset%2Fmcp_service%2Fchart%2Ftool%2Fget_chart_data.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3VwZXJzZXQvbWNwX3NlcnZpY2UvY2hhcnQvdG9vbC9nZXRfY2hhcnRfZGF0YS5weQ==) | 28.57% | [5 Missing :warning: ](https://app.codecov.io/gh/apache/superset/pull/39438?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
| [superset/mcp\_service/chart/tool/update\_chart.py](https://app.codecov.io/gh/apache/superset/pull/39438?src=pr&el=tree&filepath=superset%2Fmcp_service%2Fchart%2Ftool%2Fupdate_chart.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3VwZXJzZXQvbWNwX3NlcnZpY2UvY2hhcnQvdG9vbC91cGRhdGVfY2hhcnQucHk=) | 20.00% | [4 Missing :warning: ](https://app.codecov.io/gh/apache/superset/pull/39438?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
| [superset/mcp\_service/chart/tool/get\_chart\_info.py](https://app.codecov.io/gh/apache/superset/pull/39438?src=pr&el=tree&filepath=superset%2Fmcp_service%2Fchart%2Ftool%2Fget_chart_info.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3VwZXJzZXQvbWNwX3NlcnZpY2UvY2hhcnQvdG9vbC9nZXRfY2hhcnRfaW5mby5weQ==) | 33.33% | [2 Missing :warning: ](https://app.codecov.io/gh/apache/superset/pull/39438?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/39438?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==) | 60.00% | [2 Missing :warning: ](https://app.codecov.io/gh/apache/superset/pull/39438?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
| [...set/mcp\_service/chart/tool/update\_chart\_preview.py](https://app.codecov.io/gh/apache/superset/pull/39438?src=pr&el=tree&filepath=superset%2Fmcp_service%2Fchart%2Ftool%2Fupdate_chart_preview.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3VwZXJzZXQvbWNwX3NlcnZpY2UvY2hhcnQvdG9vbC91cGRhdGVfY2hhcnRfcHJldmlldy5weQ==) | 66.66% | [2 Missing :warning: ](https://app.codecov.io/gh/apache/superset/pull/39438?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
| [superset/mcp\_service/chart/tool/generate\_chart.py](https://app.codecov.io/gh/apache/superset/pull/39438?src=pr&el=tree&filepath=superset%2Fmcp_service%2Fchart%2Ftool%2Fgenerate_chart.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3VwZXJzZXQvbWNwX3NlcnZpY2UvY2hhcnQvdG9vbC9nZW5lcmF0ZV9jaGFydC5weQ==) | 50.00% | [1 Missing :warning: ](https://app.codecov.io/gh/apache/superset/pull/39438?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
| [.../mcp\_service/explore/tool/generate\_explore\_link.py](https://app.codecov.io/gh/apache/superset/pull/39438?src=pr&el=tree&filepath=superset%2Fmcp_service%2Fexplore%2Ftool%2Fgenerate_explore_link.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3VwZXJzZXQvbWNwX3NlcnZpY2UvZXhwbG9yZS90b29sL2dlbmVyYXRlX2V4cGxvcmVfbGluay5weQ==) | 50.00% | [1 Missing :warning: ](https://app.codecov.io/gh/apache/superset/pull/39438?src=pr&el=tree&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 #39438 +/- ##
==========================================
- Coverage 64.49% 55.45% -9.05%
==========================================
Files 2557 2559 +2
Lines 133097 133076 -21
Branches 30910 30897 -13
==========================================
- Hits 85846 73792 -12054
- Misses 45761 58633 +12872
+ Partials 1490 651 -839
```
| [Flag](https://app.codecov.io/gh/apache/superset/pull/39438/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/39438/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `39.91% <9.88%> (+0.04%)` | :arrow_up: |
| [mysql](https://app.codecov.io/gh/apache/superset/pull/39438/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/39438/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/39438/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `41.70% <9.88%> (+0.04%)` | :arrow_up: |
| [python](https://app.codecov.io/gh/apache/superset/pull/39438/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `41.77% <9.88%> (-20.39%)` | :arrow_down: |
| [sqlite](https://app.codecov.io/gh/apache/superset/pull/39438/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/39438/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
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 Sentry](https://app.codecov.io/gh/apache/superset/pull/39438?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] chore(mcp): extract shared chart helpers and ASCII rendering into separate modules [superset]
Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #39438:
URL: https://github.com/apache/superset/pull/39438#issuecomment-4291471989
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 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] chore(mcp): extract shared chart helpers and ASCII rendering into separate modules [superset]
Posted by "aminghadersohi (via GitHub)" <gi...@apache.org>.
aminghadersohi commented on code in PR #39438:
URL: https://github.com/apache/superset/pull/39438#discussion_r3120279554
##########
superset/mcp_service/chart/tool/get_chart_data.py:
##########
@@ -166,25 +154,9 @@ async def get_chart_data( # noqa: C901
# Find the chart by identifier
with event_logger.log_context(action="mcp.get_chart_data.chart_lookup"):
- if isinstance(request.identifier, int) or (
- isinstance(request.identifier, str) and request.identifier.isdigit()
- ):
- chart_id = (
- int(request.identifier)
- if isinstance(request.identifier, str)
- else request.identifier
- )
- await ctx.debug(
- "Performing ID-based chart lookup: chart_id=%s" % (chart_id,)
- )
- chart = ChartDAO.find_by_id(chart_id)
- elif isinstance(request.identifier, str):
- await ctx.debug(
- "Performing UUID-based chart lookup: uuid=%s"
- % (request.identifier,)
- )
- # Try UUID lookup using DAO flexible method
- chart = ChartDAO.find_by_id(request.identifier, id_column="uuid")
+ await ctx.debug("Looking up chart: identifier=%s" % (request.identifier,))
+ assert request.identifier is not None # validated earlier
+ chart = find_chart_by_identifier(request.identifier)
Review Comment:
Already addressed in commit 4d1548b — replaced `assert` with explicit `if request.identifier is None` validation that returns a structured `ChartError`.
##########
superset/mcp_service/chart/tool/get_chart_preview.py:
##########
@@ -1921,25 +1058,12 @@ def __init__(self, fd: Dict[str, Any]):
error_type="NotFound",
)
- elif isinstance(request.identifier, int) or (
- isinstance(request.identifier, str) and request.identifier.isdigit()
- ):
- chart_id = (
- int(request.identifier)
- if isinstance(request.identifier, str)
- else request.identifier
- )
- await ctx.debug(
- "Performing ID-based chart lookup: chart_id=%s" % (chart_id,)
- )
- chart = ChartDAO.find_by_id(chart_id)
- elif isinstance(request.identifier, str):
+ else:
await ctx.debug(
- "Performing UUID-based chart lookup: uuid=%s"
- % (request.identifier,)
+ "Looking up chart: identifier=%s" % (request.identifier,)
)
- # Try UUID lookup using DAO flexible method
- chart = ChartDAO.find_by_id(request.identifier, id_column="uuid")
+ assert request.identifier is not None # validated earlier
+ chart = find_chart_by_identifier(request.identifier)
Review Comment:
Already addressed in commit 4d1548b — replaced `assert` with explicit `if request.identifier is None` validation that returns a structured `ChartError`.
##########
superset/mcp_service/chart/ascii_charts.py:
##########
@@ -0,0 +1,859 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+"""
+ASCII chart rendering functions for MCP chart previews.
+
+Pure rendering functions that take data in and return strings out.
+No dependencies on MCP tools, FastMCP Context, or request objects.
+"""
+
+from __future__ import annotations
+
+import logging
+import math
+from typing import Any
+
+logger = logging.getLogger(__name__)
+
+
+def generate_ascii_chart(
+ data: list[Any], chart_type: str, width: int = 80, height: int = 20
+) -> str:
+ """Generate ASCII art chart from data."""
+ if not data:
+ return "No data available for ASCII chart"
+
+ try:
+ logger.debug(
+ "generate_ascii_chart: chart_type=%s, data_rows=%s", chart_type, len(data)
+ )
+
+ if chart_type in ["bar", "column", "echarts_timeseries_bar"]:
Review Comment:
Already addressed in commit 41b73fd — added `width = max(width, 21)` and `height = max(height, 9)` clamp before chart-type dispatch (lines 43-44).
##########
superset/mcp_service/chart/tool/update_chart_preview.py:
##########
@@ -123,9 +126,7 @@ def update_chart_preview(
explore_url = generate_explore_link(request.dataset_id, new_form_data)
# Extract new form_data_key from the explore URL
- new_form_data_key = None
- if "form_data_key=" in explore_url:
- new_form_data_key = explore_url.split("form_data_key=")[1].split("&")[0]
+ new_form_data_key = extract_form_data_key_from_url(explore_url)
Review Comment:
Already addressed in commit 41b73fd — added validation at line 130 that returns a structured error dict with `error_type: PreviewError` when `form_data_key` is missing, instead of silently succeeding.
--
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] chore(mcp): extract shared chart helpers and ASCII rendering into separate modules [superset]
Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #39438:
URL: https://github.com/apache/superset/pull/39438#issuecomment-4291822526
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 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