bito-code-review[bot] commented on PR #42193:
URL: https://github.com/apache/superset/pull/42193#issuecomment-5010494324

   <!-- Bito Reply -->
   The flagged issue is correct. When a user provides a filename with an 
extension (e.g., `my_export.csv`), `generate_download_headers` appends the 
format extension again, resulting in double extensions like `my_export.csv.csv`.
   
   To resolve this, you should strip the extension from the provided 
`export_filename` before passing it to `generate_download_headers`. You can use 
`os.path.splitext` for this purpose.
   
   ### Proposed Fix
   
   In `superset/charts/data/api.py`, update the `_send_chart_response` method 
to normalize the filename:
   
   ```python
   import os
   
   # ... inside _send_chart_response ...
   export_filename = filename or self._get_default_export_filename(form_data)
   base_filename = os.path.splitext(export_filename)[0]
   
   if is_csv_format:
       return CsvResponse(
           data, headers=generate_download_headers("csv", base_filename)
       )
   ```
   
   Since there are no other comments in the provided PR context, there are no 
additional issues to address.
   
   **superset/charts/data/api.py**
   ```
   import os
   
   # ... inside _send_chart_response ...
   export_filename = filename or self._get_default_export_filename(form_data)
   base_filename = os.path.splitext(export_filename)[0]
   
   if is_csv_format:
       return CsvResponse(
           data, headers=generate_download_headers("csv", base_filename)
       )
   ```


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