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


##########
superset/mcp_service/chart/schemas.py:
##########
@@ -827,12 +899,17 @@ class XYChartConfig(BaseModel):
     )
     kind: Literal["line", "bar", "area", "scatter"] = "line"
     time_grain: TimeGrain | None = Field(
-        None, description="PT1S, PT1M, PT1H, P1D, P1W, P1M, P3M, P1Y"
+        None,
+        description="PT1S, PT1M, PT1H, P1D, P1W, P1M, P3M, P1Y",
+        validation_alias=AliasChoices("time_grain", "time_grain_sqla"),
     )
     orientation: Literal["vertical", "horizontal"] | None = Field(
         None, description="Bar orientation (only for kind='bar')"
     )
-    stacked: bool = False
+    stacked: bool = Field(

Review Comment:
   **Suggestion:** The new `stack` alias only accepts boolean values, but 
Superset form data commonly uses `"stack": "Stack"`. With the current type, 
requests using the internal field/value pair will fail validation even though 
the alias is intended to support that format. Allow the `"Stack"` literal as an 
accepted input so alias-based requests don't break. [type error]
   
   <details>
   <summary><b>Severity Level:</b> Major ⚠️</summary>
   
   ```mdx
   - ⚠️ generate_chart rejects internal `stack:"Stack"` payloads.
   - ⚠️ update_chart rejects copied Superset form_data configs.
   - ⚠️ generate_explore_link fails for stacked legacy-style requests.
   ```
   </details>
   
   ```suggestion
       stacked: bool | Literal["Stack"] = Field(
   ```
   <details>
   <summary><b>Steps of Reproduction ✅ </b></summary>
   
   ```mdx
   1. Call any chart-config endpoint using `ChartConfig` (e.g. `generate_chart`,
   `update_chart`, `generate_explore_link`), which all parse request models via
   `@parse_request(...)` 
(`superset/mcp_service/chart/tool/generate_chart.py:135`,
   `.../update_chart.py:57`, `.../explore/tool/generate_explore_link.py:51`).
   
   2. Send XY config with internal Superset-style stacking input:
   
`{"chart_type":"xy","x":{"name":"date"},"y":[{"name":"sales","aggregate":"SUM"}],"stack":"Stack"}`.
   
   3. Request parsing reaches `GenerateChartRequest`/`ChartConfig` validation; 
XY schema
   defines `stacked` as `bool` with alias `"stack"`
   (`superset/mcp_service/chart/schemas.py:909-912`), so `"Stack"` is 
type-invalid for bool.
   
   4. This fails during Pydantic model parsing (before chart mapping), even 
though mapper
   emits the internal value `"Stack"` for stacked charts
   (`superset/mcp_service/chart/chart_utils.py:606-607`), showing a real 
input/output
   mismatch.
   
   5. The mismatch is also reflected in repository usage of internal form-data 
value
   `"stack": "Stack"` (e.g. migration tests at
   `tests/unit_tests/migrations/viz/nvd3_bar_chart_to_echarts_test.py:38,58`), 
making this a
   realistic compatibility issue when reusing Superset-style config payloads.
   ```
   </details>
   <details>
   <summary><b>Prompt for AI Agent 🤖 </b></summary>
   
   ```mdx
   This is a comment left during a code review.
   
   **Path:** superset/mcp_service/chart/schemas.py
   **Line:** 909:909
   **Comment:**
        *Type Error: The new `stack` alias only accepts boolean values, but 
Superset form data commonly uses `"stack": "Stack"`. With the current type, 
requests using the internal field/value pair will fail validation even though 
the alias is intended to support that format. Allow the `"Stack"` literal as an 
accepted input so alias-based requests don't break.
   
   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.
   ```
   </details>
   <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F38848&comment_hash=1a4bf812e479fd2022fb047a2c926b9bea4982560c3102c998e353101cdf1ce0&reaction=like'>👍</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F38848&comment_hash=1a4bf812e479fd2022fb047a2c926b9bea4982560c3102c998e353101cdf1ce0&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]

Reply via email to