codeant-ai-for-open-source[bot] commented on code in PR #44464:
URL: https://github.com/apache/superset/pull/44464#discussion_r4112263723


##########
superset/mcp_service/chart/schemas.py:
##########
@@ -2350,6 +2350,38 @@ class XYChartConfig(BaseChartConfig):
         ge=1,
         le=10000,
     )
+    sort_by: SortByConfig | str | List[SortByConfig | str] | None = Field(
+        None,
+        description=(
+            "Sort specification for the chart. Accepts a SortByConfig object, "
+            "a bare column/metric name string (defaults to descending), or a "
+            "single-item list containing either."
+        ),
+        validation_alias=AliasChoices("sort_by", "x_axis_sort", "order_by"),
+    )
+
+    @field_validator("sort_by", mode="before")
+    @classmethod
+    def coerce_sort_by(cls, v: Any) -> Any:
+        """Coerce bare string, dict, or single-item list into SortByConfig."""
+        if v is None:
+            return None
+        if isinstance(v, str):
+            return SortByConfig(column=v, ascending=False)
+        if isinstance(v, list):
+            if not v:
+                return None
+            first = v[0]
+            if isinstance(first, str):
+                return SortByConfig(column=first, ascending=False)

Review Comment:
   ✅ **CodeAnt verified this suggestion was addressed in subsequent commits and 
marked this thread resolved** as of `ff3dc4e`.
   
   Multi-item sort lists are now rejected with a clear validation error instead 
of being reduced to the first entry. The field description also documents that 
XY charts support only a single sort column.
   
   <sub>If that's not right, unresolve this thread and CodeAnt will leave it 
open.</sub>
   
   <!-- codeant-auto-resolve-reply -->



-- 
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]

Reply via email to