bito-code-review[bot] commented on code in PR #44393:
URL: https://github.com/apache/superset/pull/44393#discussion_r4157277911
##########
superset/mcp_service/chart/schemas.py:
##########
@@ -3783,6 +3784,32 @@ def chart_config_reference_schema(*, nullable: bool =
False) -> WithJsonSchema:
}
+def _normalize_chart_target_alias(data: dict[str, Any]) -> dict[str, Any]:
+ """Copy legacy target vocabulary without changing its datasource family."""
+ data = dict(data)
+ if "datasource_type" in data and (
+ (data.get("dataset_id") is not None and data["datasource_type"] !=
"table")
+ or (
+ data.get("view_id") is not None
+ and data["datasource_type"] != "semantic_view"
+ )
+ ):
+ raise ValueError("datasource_type conflicts with the explicit chart
target")
+ if "datasource_id" in data:
+ source_type: object = data.get("datasource_type", "table")
+ if source_type not in ("table", "semantic_view"):
+ raise ValueError("datasource_type must be table or semantic_view")
+ target_key: str = "view_id" if source_type == "semantic_view" else
"dataset_id"
+ other_key: str = "dataset_id" if target_key == "view_id" else "view_id"
+ source_id: object = data.pop("datasource_id")
+ if data.get(other_key) is not None or (
+ data.get(target_key) is not None and data[target_key] != source_id
+ ):
+ raise ValueError("datasource_id conflicts with the explicit chart
target")
+ data[target_key] = source_id
Review Comment:
<!-- Bito Reply -->
The analysis correctly identifies that the `ValidationPipeline` is not
involved in semantic target requests, as these follow a separate branch that
calls `validate_semantic_view_config` directly. Since table requests are the
only ones entering the `ValidationPipeline`, the dataset requirement does not
apply to semantic targets, making the suggested alignment unnecessary for this
specific path.
--
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]