dosubot[bot] commented on issue #37487:
URL: https://github.com/apache/superset/issues/37487#issuecomment-3804420613

   <!-- Answer -->
   Superset currently names exported files using a timestamp (like 
`20260127_160233`) because the backend function that generates download headers 
defaults to this pattern if no filename is provided. This happens in the 
`generate_download_headers` function in `superset/views/base.py` and is used by 
export endpoints without passing the chart or dashboard name, resulting in 
generic filenames for all exports 
[(source)](https://github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/superset/views/base.py#L141-L147).
   
   To use the chart or dashboard name in the exported file name, you can update 
the export logic to pass the relevant name to `generate_download_headers`. For 
charts, the name is available as `slice_name`; for dashboards, it's 
`dashboard_title`. You should sanitize these names to remove special characters 
and consider appending a unique identifier (like the chart or dashboard UUID) 
to avoid filename collisions, since names are not guaranteed to be unique 
[(discussion)](https://github.com/apache/superset/issues/33784).
   
   For example, in the CSV export logic, instead of:
   ```python
   headers = generate_download_headers("csv")
   ```
   you could use:
   ```python
   filename = f"{viz_obj.slice_name}_{viz_obj.slice_id}"  # sanitize as needed
   headers = generate_download_headers("csv", filename)
   ```
   A similar approach applies for dashboards.
   
   There are no configuration or UI options to customize export filenames at 
this time; this change requires a code update. There are open issues and pull 
requests discussing improvements to export file naming, including using asset 
names and UUIDs for clarity and stability 
[(issue)](https://github.com/apache/superset/issues/32987) 
[(PR)](https://github.com/apache/superset/pull/35828).
   
   If you implement this, make sure to handle special characters and test with 
non-ASCII names to avoid encoding issues.
   
   
   <!-- Dosu Comment Footer -->
   *To reply, just mention [@dosu](https://go.dosu.dev/dosubot).*
   
   ---
   <sup>How did I do? 
[Good](https://app.dosu.dev/response-feedback/2a5b8fe7-2888-4350-910a-858576700150?feedback_type=great_response)
 | 
[Irrelevant](https://app.dosu.dev/response-feedback/2a5b8fe7-2888-4350-910a-858576700150?feedback_type=irrelevant_answer)
 | 
[Incorrect](https://app.dosu.dev/response-feedback/2a5b8fe7-2888-4350-910a-858576700150?feedback_type=incorrect_sources)
 | 
[Verbose](https://app.dosu.dev/response-feedback/2a5b8fe7-2888-4350-910a-858576700150?feedback_type=too_verbose)
 | 
[Hallucination](https://app.dosu.dev/response-feedback/2a5b8fe7-2888-4350-910a-858576700150?feedback_type=hallucination)
 | [Report 
🐛](https://app.dosu.dev/response-feedback/2a5b8fe7-2888-4350-910a-858576700150?feedback_type=bug_report)
 | 
[Other](https://app.dosu.dev/response-feedback/2a5b8fe7-2888-4350-910a-858576700150?feedback_type=other)</sup>
   
   [![Chat with 
Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/a28d3c7e-a9d3-459e-9fb6-3a6f9ff4f357/ask?utm_source=github)&nbsp;[![Open
 in 
Cursor](https://dosu.dev/dosu-in-cursor.svg)](https://cursor.com/link/prompt?text=Superset%20currently%20names%20exported%20files%20using%20a%20timestamp%20%28like%20%6020260127_160233%60%29%20because%20the%20backend%20function%20that%20generates%20download%20headers%20defaults%20to%20this%20pattern%20if%20no%20filename%20is%20provided.%20This%20happens%20in%20the%20%60generate_download_headers%60%20function%20in%20%60superset/views/base.py%60%20and%20is%20used%20by%20export%20endpoints%20without%20passing%20the%20chart%20or%20dashboard%20name%2C%20resulting%20in%20generic%20filenames%20for%20all%20exports%20%5B%28source%29%5D%28https%3A//github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/superset/views/base.py%23L141-L147%29.%0A%0ATo%20use%20the%20chart%20or%20dashboard%20name%20in%20the%20exported%20file%
 
20name%2C%20you%20can%20update%20the%20export%20logic%20to%20pass%20the%20relevant%20name%20to%20%60generate_download_headers%60.%20For%20charts%2C%20the%20name%20is%20available%20as%20%60slice_name%60%3B%20for%20dashboards%2C%20it%27s%20%60dashboard_title%60.%20You%20should%20sanitize%20these%20names%20to%20remove%20special%20characters%20and%20consider%20appending%20a%20unique%20identifier%20%28like%20the%20chart%20or%20dashboard%20UUID%29%20to%20avoid%20filename%20collisions%2C%20since%20names%20are%20not%20guaranteed%20to%20be%20unique%20%5B%28discussion%29%5D%28https%3A//github.com/apache/superset/issues/33784%29.%0A%0AFor%20example%2C%20in%20the%20CSV%20export%20logic%2C%20instead%20of%3A%0A%60%60%60python%0Aheaders%20%3D%20generate_download_headers%28%22csv%22%29%0A%60%60%60%0Ayou%20could%20use%3A%0A%60%60%60python%0Afilename%20%3D%20f%22%7Bviz_obj.slice_name%7D_%7Bviz_obj.slice_id%7D%22%20%20%23%20sanitize%20as%20needed%0Aheaders%20%3D%20generate_download_headers%28%22csv%22
 
%2C%20filename%29%0A%60%60%60%0AA%20similar%20approach%20applies%20for%20dashboards.%0A%0AThere%20are%20no%20configuration%20or%20UI%20options%20to%20customize%20export%20filenames%20at%20this%20time%3B%20this%20change%20requires%20a%20code%20update.%20There%20are%20open%20issues%20and%20pull%20requests%20discussing%20improvements%20to%20export%20file%20naming%2C%20including%20using%20asset%20names%20and%20UUIDs%20for%20clarity%20and%20stability%20%5B%28issue%29%5D%28https%3A//github.com/apache/superset/issues/32987%29%20%5B%28PR%29%5D%28https%3A//github.com/apache/superset/pull/35828%29.%0A%0AIf%20you%20implement%20this%2C%20make%20sure%20to%20handle%20special%20characters%20and%20test%20with%20non-ASCII%20names%20to%20avoid%20encoding%20issues.)&nbsp;[![Join
 
Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share
 on 
X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%4
 
0dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/apache/superset/issues/37487)


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