codeant-ai-for-open-source[bot] commented on code in PR #43737:
URL: https://github.com/apache/superset/pull/43737#discussion_r3899582545
##########
superset/mcp_service/chart/preview_utils.py:
##########
@@ -469,11 +446,288 @@ def _is_nan(value: Any) -> bool:
return False
+def _gantt_metric_label(metric: Any) -> str | None:
+ """Resolve a native metric result key like frontend ``getMetricLabel``."""
+ if isinstance(metric, str) and metric:
+ return metric
+ if not isinstance(metric, dict) or not 0 < len(metric) <= 20:
+ return None
+
+ label = metric.get("label")
+ if label:
+ return label if isinstance(label, str) else None
+ if label not in (None, ""):
+ return None
+
+ expression_type = metric.get("expressionType")
+ if expression_type == "SIMPLE":
+ aggregate = metric.get("aggregate")
+ column = metric.get("column")
+ if (
+ not isinstance(aggregate, str)
+ or not aggregate
+ or len(aggregate) > 100
+ or not isinstance(column, dict)
+ or not 0 < len(column) <= 50
+ ):
+ return None
+ column_name = column.get("columnName") or column.get("column_name")
+ if not isinstance(column_name, str) or not column_name:
+ return None
+ return f"{aggregate}({column_name})"
+ if expression_type == "SQL":
+ sql_expression = metric.get("sqlExpression")
+ if (
+ isinstance(sql_expression, str)
+ and sql_expression
+ and len(sql_expression) <= 2000
+ ):
+ return sql_expression
+ return None
+
+
+def _gantt_result_field(field: Any, _field_name: str) -> str | None:
+ """Resolve the query-result key using the frontend getColumnLabel
contract."""
+ if isinstance(field, str) and field:
+ return field
+ if not isinstance(field, dict) or not 0 < len(field) <= 20:
+ return None
+ label = field.get("label") or field.get("sqlExpression")
+ return label if isinstance(label, str) and label else None
Review Comment:
**Suggestion:** Physical column references use `column_name` here but are
rejected by `_gantt_result_field`, so saved Gantt previews fail for valid
native form data. [api mismatch]
**Assessment:** ๐ `Major` ยท ๐ `Occurrence: Sometimes`
[](https://docs.codeant.ai/cli/resolve-pr-comments-skill)
[](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=d8f5a86788b14e0bb69a2805292f4321&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=d8f5a86788b14e0bb69a2805292f4321&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/preview_utils.py
**Line:** 495:496
**Comment:**
*Api Mismatch: Physical column references use `column_name` here but
are rejected by `_gantt_result_field`, so saved Gantt previews fail for valid
native form data.
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%2F43737&comment_hash=e035b2d66d775cd90c2621543e79df9d978170d8d1747dc47e40a0fe41465cfe&reaction=like'>๐</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F43737&comment_hash=e035b2d66d775cd90c2621543e79df9d978170d8d1747dc47e40a0fe41465cfe&reaction=dislike'>๐</a>
##########
superset/mcp_service/chart/tool/update_chart.py:
##########
@@ -234,8 +235,10 @@ def _build_update_payload(
parsed_config, dataset_id=effective_dataset_id
)
new_form_data.pop("_mcp_warnings", None)
- merge_table_column_config(_get_existing_form_data(chart),
new_form_data)
- merge_interactive_pivot_ui_config(_get_existing_form_data(chart),
new_form_data)
+ existing_form_data = _get_existing_form_data(chart)
+ merge_table_column_config(existing_form_data, new_form_data)
+ merge_interactive_pivot_ui_config(existing_form_data, new_form_data)
+ merge_gantt_ui_config(existing_form_data, new_form_data)
Review Comment:
**Suggestion:** Gantt updates merge only presentation fields, so omitted
existing adhoc filters are discarded on save while the preview path preserves
them, causing preview and saved chart state to diverge. [api mismatch]
**Assessment:** ๐ `Major` ยท ๐ `Occurrence: Sometimes`
[](https://docs.codeant.ai/cli/resolve-pr-comments-skill)
[](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=ec177a64623b499184b893b1a4cd7d81&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=ec177a64623b499184b893b1a4cd7d81&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:** 238:241
**Comment:**
*Api Mismatch: Gantt updates merge only presentation fields, so omitted
existing adhoc filters are discarded on save while the preview path preserves
them, causing preview and saved chart state to diverge.
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%2F43737&comment_hash=b43b1cb473afaf3754ae8022e80555c64af507256f4e8f582587224ccd4c91ea&reaction=like'>๐</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F43737&comment_hash=b43b1cb473afaf3754ae8022e80555c64af507256f4e8f582587224ccd4c91ea&reaction=dislike'>๐</a>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]