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


##########
superset/commands/report/execute.py:
##########
@@ -1361,28 +1371,49 @@ def _get_embedded_data(self) -> pd.DataFrame:
         """
         start_time: datetime = datetime.now(timezone.utc).replace(tzinfo=None)
 
-        url = self._get_url(result_format=ChartDataResultFormat.JSON)
+        url: str = self._get_url(result_format=ChartDataResultFormat.JSON)
         user, username = resolve_executor_user(self._report_schedule)
         auth_cookies = 
machine_auth_provider_factory.instance.get_auth_cookies(user)
 
         if self._report_schedule.chart.query_context is None:
             logger.warning("No query context found, taking a screenshot to 
generate it")
             self._update_query_context()
+            db.session.refresh(self._report_schedule.chart)
 
         try:
-            dataframe = get_chart_dataframe(
-                url,
-                auth_cookies,
-                timeout=self._phase_timeout(
-                    "dataframe_generation",
-                    
requested_seconds=app.config["ALERT_REPORTS_CSV_REQUEST_TIMEOUT"],
-                    reserve_seconds=(
-                        
self._report_execution_context.post_capture_reserve_seconds
-                        if self._report_execution_context
-                        else 0.0
-                    ),
+            timeout: float | None = self._phase_timeout(
+                "dataframe_generation",
+                
requested_seconds=app.config["ALERT_REPORTS_CSV_REQUEST_TIMEOUT"],
+                reserve_seconds=(
+                    self._report_execution_context.post_capture_reserve_seconds
+                    if self._report_execution_context
+                    else 0.0
                 ),
             )
+            dataframe: pd.DataFrame | None
+            if self._report_schedule.chart.query_context is None:
+                dataframe = get_chart_dataframe(url, auth_cookies, 
timeout=timeout)
+            else:
+                # Match the GET endpoint's current chart settings for client 
processing.
+                form_data: dict[str, Any]
+                try:
+                    form_data = json.loads(self._report_schedule.chart.params)
+                except (TypeError, json.JSONDecodeError):
+                    form_data = {}
+                if not isinstance(form_data, dict):
+                    form_data = {}
+                request_payload: dict[str, Any] = 
self._get_chart_data_request_payload(
+                    ChartDataResultFormat.JSON, form_data=form_data
+                )
+                url = get_url_path("ChartDataRestApi.data")
+                dataframe = chart_data_to_dataframe(
+                    self._post_chart_data(
+                        chart_url=url,
+                        auth_cookies=auth_cookies,
+                        request_payload=request_payload,
+                        timeout=timeout,
+                    )
+                )

Review Comment:
   **Suggestion:** Unlike `_get_data`, this calls `_post_chart_data` outside 
`request_chart_data`; socket timeouts and transient errors skip retries and are 
reported as generic dataframe failures.
   
   **Assessment:** ๐ŸŸ  `Major` ยท ๐Ÿ” `Occurrence: Rarely` ยท ๐Ÿท๏ธ `Api mismatch`
   
   [![Use CodeAnt 
Skill](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/use-codeant-skill-flat-v2.svg)](https://docs.codeant.ai/cli/resolve-pr-comments-skill)
 [![Fix in 
Cursor](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-cursor-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=95a5d977a25b46d6b0f15743f79c6812&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
 [![Fix in VSCode 
Claude](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-vscode-claude-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=95a5d977a25b46d6b0f15743f79c6812&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/commands/report/execute.py
   **Line:** 1409:1416
   **Comment:**
        *Api Mismatch: Unlike `_get_data`, this calls `_post_chart_data` 
outside `request_chart_data`; socket timeouts and transient errors skip retries 
and are reported as generic dataframe failures.
   
   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%2F45099&comment_hash=052caafdc25ed39aa88e8a6d5730fda4edb0f434bd2dc954c423dae2595ed936&reaction=like'>๐Ÿ‘</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F45099&comment_hash=052caafdc25ed39aa88e8a6d5730fda4edb0f434bd2dc954c423dae2595ed936&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