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


##########
superset/mcp_service/chart/chart_utils.py:
##########
@@ -320,6 +320,10 @@ def map_xy_config(config: XYChartConfig) -> Dict[str, Any]:
             if filter_config is not None
         ]
 
+    # Add stacking configuration
+    if config.stacked:
+        form_data["stack"] = "Stack"

Review Comment:
   **Suggestion:** The code sets form_data["stack"] to the string "Stack"; 
Superset/ECharts typically expect a boolean or normalized value for enabling 
stacking — using a boolean is safer and less likely to be ignored; set the key 
to True instead of a string, and use getattr for defensive access to `stacked`. 
[type error]
   
   <details>
   <summary><b>Severity Level:</b> Critical 🚨</summary>
   
   ```mdx
   - ❌ Bar/area stacking may not enable visually.
   - ⚠️ generate_chart output inconsistent with other flags.
   ```
   </details>
   
   ```suggestion
       if getattr(config, "stacked", False):
           form_data["stack"] = True
   ```
   <details>
   <summary><b>Steps of Reproduction ✅ </b></summary>
   
   ```mdx
   1. Call map_xy_config() in superset/mcp_service/chart/chart_utils.py 
(function header at
   line 310) with an XYChartConfig where kind="bar" and stacked=True.
   
   2. Execution reaches lines 323-325 and sets form_data["stack"] = "Stack".
   
   3. Inspect returned form_data and note stack is the string "Stack" rather 
than a boolean.
   Other nearby code uses booleans (e.g., add_legend_config sets 
show_legend=False),
   indicating boolean usage is conventional.
   
   4. If Superset/ECharts expects a boolean flag for enabling stacking, the 
string value may
   be ignored and charts will not render as stacked. Replacing the string with 
True produces
   a conventional boolean flag.
   ```
   </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/chart_utils.py
   **Line:** 324:325
   **Comment:**
        *Type Error: The code sets form_data["stack"] to the string "Stack"; 
Superset/ECharts typically expect a boolean or normalized value for enabling 
stacking — using a boolean is safer and less likely to be ignored; set the key 
to True instead of a string, and use getattr for defensive access to `stacked`.
   
   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>



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