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


##########
superset-frontend/src/components/Chart/DrillDetail/DrillDetailPane.tsx:
##########
@@ -207,6 +219,64 @@ export default function DrillDetailPane({
     setPageIndex(0);
   }, []);
 
+  const handleDownload = useCallback(
+    (exportType: 'csv' | 'xlsx') => {
+      const drillPayload = getDrillPayload(formData, filters);
+      if (!drillPayload) {
+        addDangerToast(t('Unable to generate download payload'));
+        return;
+      }
+      const payload: JsonObject = {
+        datasource: {
+          id: parseInt(datasourceId, 10),
+          type: datasourceType,
+        },
+        queries: [
+          {
+            ...drillPayload,
+            columns: [],
+            metrics: [],
+            orderby: [],
+            row_limit: ROW_LIMIT,
+            row_offset: 0,
+          },
+        ],
+        result_type: 'drill_detail',
+        result_format: exportType,
+        force: false,
+      };
+      if (dashboardId) {
+        payload.form_data = { dashboardId };
+      }
+      SupersetClient.postForm(ensureAppRoot('/api/v1/chart/data'), {
+        form_data: safeStringify(payload),
+      }).catch(error => {
+        addDangerToast(
+          t('Failed to generate download: %s', error.message || error),
+        );
+      });

Review Comment:
   **Suggestion:** This error handler does not actually catch download 
failures: `postForm` submits a hidden browser form and cannot observe HTTP 
error responses after submission, so backend export errors will not trigger the 
toast. If you need reliable failure reporting, switch this export call to a 
request-based API path (for example a normal `post` flow that can inspect 
response status) instead of `postForm`, or remove the misleading catch path. 
[incomplete implementation]
   
   <details>
   <summary><b>Severity Level:</b> Major ⚠️</summary>
   
   ```mdx
   - ⚠️ Drill-to-detail CSV/XLSX exports lack failure toasts.
   - ⚠️ Users may miss backend export errors on downloads.
   - ⚠️ Debugging failed drill exports harder for support teams.
   ```
   </details>
   <details>
   <summary><b>Steps of Reproduction ✅ </b></summary>
   
   ```mdx
   1. Open a dashboard and use the slice header controls menu for a chart; this 
renders
   `SliceHeaderControls` at
   
`superset-frontend/src/dashboard/components/SliceHeaderControls/index.tsx:660-699`,
 which
   includes a <DrillDetailModal /> with `showModal={drillModalIsOpen}`.
   
   2. In `DrillDetailModal`
   
(`superset-frontend/src/components/Chart/DrillDetail/DrillDetailModal.tsx:140-179`),
 the
   modal body renders <DrillDetailPane formData={formData} 
initialFilters={initialFilters}
   dataset={dataset} />, wiring the drill-to-detail UI to the pane component.
   
   3. Inside `DrillDetailPane`
   
(`superset-frontend/src/components/Chart/DrillDetail/DrillDetailPane.tsx:220-289`),
 the
   `handleDownload` callback builds an export payload and calls
   `SupersetClient.postForm(ensureAppRoot('/api/v1/chart/data'), { form_data:
   safeStringify(payload) }).catch(error => addDangerToast(...))`.
   
   4. The download dropdown in `TableControls`
   
(`superset-frontend/src/components/Chart/DrillDetail/DrillDetailTableControls.tsx:138-147`)
   invokes `onDownloadCSV`/`onDownloadXLSX`, which are 
`handleDownload('csv'|'xlsx')` from
   `DrillDetailPane`; when the user clicks CSV/XLSX download, the browser 
submits a hidden
   form via `SupersetClientClass.postForm`
   (`packages/superset-ui-core/src/connection/SupersetClientClass.ts:118-150`), 
which just
   creates and submits a <form> element and does not inspect the HTTP response 
status.
   
   5. If the backend `/api/v1/chart/data` export fails (e.g. returns HTTP 500 
or an HTML
   error page instead of a file), the hidden form submission completes without 
throwing; the
   async `postForm` call resolves successfully, so the `.catch` block in 
`DrillDetailPane` at
   lines 251-257 is never triggered and the "Failed to generate download" 
danger toast is not
   shown, despite the download having failed.
   ```
   </details>
   
   [![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=dc975a26d2024937a1484517c9904361&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=dc975a26d2024937a1484517c9904361&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
   
   *(Use Cmd/Ctrl + Click for best experience)*
   <details>
   <summary><b>Prompt for AI Agent 🤖 </b></summary>
   
   ```mdx
   This is a comment left during a code review.
   
   **Path:** 
superset-frontend/src/components/Chart/DrillDetail/DrillDetailPane.tsx
   **Line:** 251:257
   **Comment:**
        *Incomplete Implementation: This error handler does not actually catch 
download failures: `postForm` submits a hidden browser form and cannot observe 
HTTP error responses after submission, so backend export errors will not 
trigger the toast. If you need reliable failure reporting, switch this export 
call to a request-based API path (for example a normal `post` flow that can 
inspect response status) instead of `postForm`, or remove the misleading catch 
path.
   
   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%2F41937&comment_hash=7e47112a335260a88f82bac973ab8b505d13b5ad279c93e8db2d4be9e63effb6&reaction=like'>👍</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41937&comment_hash=7e47112a335260a88f82bac973ab8b505d13b5ad279c93e8db2d4be9e63effb6&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