You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by "shafad1 (via GitHub)" <gi...@apache.org> on 2026/01/27 10:35:23 UTC

[I] Exported file name is coming as a random string . [superset]

shafad1 opened a new issue, #37487:
URL: https://github.com/apache/superset/issues/37487

   ### Bug description
   
   Exporting reports should keep the chart name or dashboard name as file name , instead appending only date with string which is not best practice , how can we update with chart or dashboard name 
   
   <img width="516" height="176" alt="Image" src="https://github.com/user-attachments/assets/73079292-7139-46f4-9546-5dea3ea586a6" />
   
   ### Screenshots/recordings
   
   _No response_
   
   ### Superset version
   
   master / latest-dev
   
   ### Python version
   
   3.9
   
   ### Node version
   
   16
   
   ### Browser
   
   Chrome
   
   ### Additional context
   
   _No response_
   
   ### Checklist
   
   - [ ] I have searched Superset docs and Slack and didn't find a solution to my problem.
   - [ ] I have searched the GitHub issue tracker and didn't find a similar bug report.
   - [ ] I have checked Superset's logs for errors and if I found a relevant Python stacktrace, I included it here as text in the "additional context" section.


-- 
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: notifications-unsubscribe@superset.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [I] Exported file name is coming as a random string . [superset]

Posted by "shafad1 (via GitHub)" <gi...@apache.org>.
shafad1 commented on issue #37487:
URL: https://github.com/apache/superset/issues/37487#issuecomment-3805561738

   its not reflecting  , can you share the file names and code sections to
   customize it
   
   
   Thanks and Regards
   Muhammed Shafad
   Senior Data Analyst.
   
   
   On Tue, Jan 27, 2026 at 4:10 PM dosubot[bot] ***@***.***>
   wrote:
   
   > *dosubot[bot]* left a comment (apache/superset#37487)
   > <https://github.com/apache/superset/issues/37487#issuecomment-3804420613>
   >
   > 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:
   >
   > headers = generate_download_headers("csv")
   >
   > you could use:
   >
   > filename = f"{viz_obj.slice_name}_{viz_obj.slice_id}"  # sanitize as neededheaders = 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.
   >
   > *To reply, just mention @dosu <https://go.dosu.dev/dosubot>.*
   > ------------------------------
   >
   > 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>
   >
   > [image: Chat with Dosu]
   > <https://app.dosu.dev/a28d3c7e-a9d3-459e-9fb6-3a6f9ff4f357/ask?utm_source=github>
   >  [image: Open in Cursor]
   > <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%20tim
 e%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.>
   >  [image: Join Discord] <https://go.dosu.dev/discord-bot> [image: Share on
   > X]
   > <https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/apache/superset/issues/37487>
   >
   > —
   > Reply to this email directly, view it on GitHub
   > <https://github.com/apache/superset/issues/37487#issuecomment-3804420613>,
   > or unsubscribe
   > <https://github.com/notifications/unsubscribe-auth/AZUMNEHX2VS6HQEC7O34HLL4I46C5AVCNFSM6AAAAACTAVIXQGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTQMBUGQZDANRRGM>
   > .
   > You are receiving this because you authored the thread.Message ID:
   > ***@***.***>
   >
   


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [I] Exported file name is coming as a random string . [superset]

Posted by "Shivanigundlapalli (via GitHub)" <gi...@apache.org>.
Shivanigundlapalli commented on issue #37487:
URL: https://github.com/apache/superset/issues/37487#issuecomment-3817954345

   Hi @maintainers   
   
   I’ve gone through the issue and the discussion above, including the suggested areas in
   `superset/charts/data/api.py`, `superset/dashboards/api.py`, and `generate_download_headers`.
   
   I’d like to work on this issue by implementing a consistent and user-friendly export filename strategy for both charts and dashboards, including:
   - using chart/dashboard names,
   - sanitizing filenames safely,
   - and avoiding collisions (e.g. with IDs/UUIDs).
   
   Before starting, I wanted to confirm:
   - whether this approach aligns with current expectations, and
   - if it’s okay for me to proceed with a PR for this issue.
   
   Happy to incorporate feedback before coding.  
   Thanks!
   


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [I] Exported file name is coming as a random string . [superset]

Posted by "shafad1 (via GitHub)" <gi...@apache.org>.
shafad1 commented on issue #37487:
URL: https://github.com/apache/superset/issues/37487#issuecomment-3817990541

   I have implemented this , we can pass slice name in the header
   
   Thanks and Regards
   Muhammed Shafad
   Senior Data Analyst.
   
   
   On Thu, 29 Jan 2026 at 7:43 PM, Shivanigundlapalli ***@***.***>
   wrote:
   
   > *Shivanigundlapalli* left a comment (apache/superset#37487)
   > <https://github.com/apache/superset/issues/37487#issuecomment-3817954345>
   >
   > Hi @maintainers <https://github.com/maintainers>
   >
   > I’ve gone through the issue and the discussion above, including the
   > suggested areas in
   > superset/charts/data/api.py, superset/dashboards/api.py, and
   > generate_download_headers.
   >
   > I’d like to work on this issue by implementing a consistent and
   > user-friendly export filename strategy for both charts and dashboards,
   > including:
   >
   >    - using chart/dashboard names,
   >    - sanitizing filenames safely,
   >    - and avoiding collisions (e.g. with IDs/UUIDs).
   >
   > Before starting, I wanted to confirm:
   >
   >    - whether this approach aligns with current expectations, and
   >    - if it’s okay for me to proceed with a PR for this issue.
   >
   > Happy to incorporate feedback before coding.
   > Thanks!
   >
   > —
   > Reply to this email directly, view it on GitHub
   > <https://github.com/apache/superset/issues/37487#issuecomment-3817954345>,
   > or unsubscribe
   > <https://github.com/notifications/unsubscribe-auth/AZUMNEBFKSUDAHAGHE2A4MD4JIIRBAVCNFSM6AAAAACTAVIXQGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTQMJXHE2TIMZUGU>
   > .
   > You are receiving this because you authored the thread.Message ID:
   > ***@***.***>
   >
   


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [I] Exported file name is coming as a random string . [superset]

Posted by "shafad1 (via GitHub)" <gi...@apache.org>.
shafad1 commented on issue #37487:
URL: https://github.com/apache/superset/issues/37487#issuecomment-3819328765

   Hi  ,
   
   As per our customer experience , they are not comfortable with apache
   superset due to some compatibility issues interms of user experiences .
   1. The default date input filter is having multiple navigation through the
   popup . it would be great if we could make date range as a separate filter
   like bootstrap date picker .
   2.The exported file was not able to append the report name which i have
   customized for my projects
   3.excel export cannot keep the header style , only kept data .
   4.Superset generates unnecessary outer loop in sql query , its impacting
   the performance
   
   Thanks and Regards
   Shafad
   
   
   
   
   
   Thanks and Regards
   Muhammed Shafad
   Senior Data Analyst.
   
   
   On Thu, Jan 29, 2026 at 7:55 PM Shivanigundlapalli ***@***.***>
   wrote:
   
   > *Shivanigundlapalli* left a comment (apache/superset#37487)
   > <https://github.com/apache/superset/issues/37487#issuecomment-3818025283>
   >
   > Thanks for the update @shafad1 <https://github.com/shafad1>
   > Glad to know this is already implemented.
   >
   > I’ll hold off on this issue for now.
   > Happy to help review or test the PR once it’s available.
   >
   > Thanks!
   >
   > —
   > Reply to this email directly, view it on GitHub
   > <https://github.com/apache/superset/issues/37487#issuecomment-3818025283>,
   > or unsubscribe
   > <https://github.com/notifications/unsubscribe-auth/AZUMNEHAMXYCLNKNWPYLRHL4JIJ6XAVCNFSM6AAAAACTAVIXQGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTQMJYGAZDKMRYGM>
   > .
   > You are receiving this because you were mentioned.Message ID:
   > ***@***.***>
   >
   


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [I] Exported file name is coming as a random string . [superset]

Posted by "rusackas (via GitHub)" <gi...@apache.org>.
rusackas commented on issue #37487:
URL: https://github.com/apache/superset/issues/37487#issuecomment-3861916439

   Please do link it to the PR if there is one, or open a PR if there's not! Thanks in advance!
   
   (or, if this is irrelevant, we can close it)


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [I] Exported file name is coming as a random string . [superset]

Posted by "rusackas (via GitHub)" <gi...@apache.org>.
rusackas closed issue #37487: Exported file name is coming as a random string .
URL: https://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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [I] Exported file name is coming as a random string . [superset]

Posted by "Shivanigundlapalli (via GitHub)" <gi...@apache.org>.
Shivanigundlapalli commented on issue #37487:
URL: https://github.com/apache/superset/issues/37487#issuecomment-3824168968

   Thanks @sadpandajoe, that makes sense 
   
   Since this doesn’t appear to be merged upstream yet, I’m happy to take this up.
   I’ll work on a clean implementation for the main Superset codebase (not a fork),
   and open a PR that:
   
   - uses chart/dashboard names in exported filenames,
   - safely sanitizes filenames,
   - avoids collisions (ID/UUID where needed),
   - keeps backward compatibility.
   
   I’ll link the PR here once ready.  
   Please let me know if there’s anything specific you’d like me to consider.
   Thanks!
   


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [I] Exported file name is coming as a random string . [superset]

Posted by "Shivanigundlapalli (via GitHub)" <gi...@apache.org>.
Shivanigundlapalli commented on issue #37487:
URL: https://github.com/apache/superset/issues/37487#issuecomment-3818025283

   Thanks for the update @shafad1   
   Glad to know this is already implemented.
   
   I’ll hold off on this issue for now.  
   Happy to help review or test the PR once it’s available.
   
   Thanks!
   


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [I] Exported file name is coming as a random string . [superset]

Posted by "sadpandajoe (via GitHub)" <gi...@apache.org>.
sadpandajoe commented on issue #37487:
URL: https://github.com/apache/superset/issues/37487#issuecomment-3821214434

   @Shivanigundlapalli feel free to just contribute if it's easy. It sounds like this may be implemented in someone's personal fork instead. If we don't think this is necessary anymore we can just close out the issue.


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [I] Exported file name is coming as a random string . [superset]

Posted by "dosubot[bot] (via GitHub)" <gi...@apache.org>.
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [I] Exported file name is coming as a random string . [superset]

Posted by "dosubot[bot] (via GitHub)" <gi...@apache.org>.
dosubot[bot] commented on issue #37487:
URL: https://github.com/apache/superset/issues/37487#issuecomment-3805633737

   <!-- Answer -->
   Here are the files and code sections you need to customize export filenames in Superset:
   
   **1. Chart exports (CSV/XLSX/ZIP):**
   - File: `superset/charts/data/api.py`
   - Method: `_send_chart_response`
   - By default, this method calls `generate_download_headers("csv")` (or `"xlsx"`, `"zip"`) with no filename, so you get a timestamp-based name.  
   - To use the chart name and ID, modify the call like:
     ```python
     from werkzeug.utils import secure_filename
     chart_name = secure_filename(result["query_context"].form_data.get("slice_name", "chart"))
     chart_id = result["query_context"].form_data.get("slice_id", "id")
     filename = f"{chart_name}_{chart_id}"
     headers = generate_download_headers("csv", filename)
     ```
     Do similar for XLSX and ZIP exports.  
     [Reference](https://github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/superset/charts/data/api.py#L346-L411)
   
   **2. Dashboard exports (YAML ZIP):**
   - File: `superset/dashboards/api.py`
   - Method: `export`
   - The ZIP filename is set by:
     ```python
     timestamp = datetime.now().strftime("%Y%m%dT%H%M%S")
     root = f"dashboard_export_{timestamp}"
     filename = f"{root}.zip"
     ```
   - Change this to use dashboard titles and IDs. For example:
     ```python
     from superset.utils.file import get_filename
     dashboards = [DashboardDAO.find_by_id(did) for did in requested_ids]
     name_tokens = [get_filename(d.dashboard_title, d.id) for d in dashboards if d]
     root = "_".join(name_tokens)
     filename = f"{root}.zip"
     ```
     [Reference](https://github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/superset/dashboards/api.py#L1002-L1023)
   
   **3. Download header helper:**
   - File: `superset/views/base.py`
   - Function: `generate_download_headers`
   - This function just takes your filename and extension and sets the HTTP header. It does not sanitize or deduplicate, so do that before calling it.
     [Reference](https://github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/superset/views/base.py#L141-L147)
   
   **Checklist:**
   - Extract chart/dashboard name and ID/UUID in the export method.
   - Sanitize the name (use `secure_filename` or similar).
   - Pass the sanitized filename to `generate_download_headers` (charts) or as `download_name` in `send_file` (dashboards).
   - Test with special characters and non-ASCII names.
   
   Let me know if you need a more detailed code sample for a specific export type.
   
   
   <!-- 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/3364c7b1-fe3d-40c0-ab1d-c9dee9ab7c07?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/3364c7b1-fe3d-40c0-ab1d-c9dee9ab7c07?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/3364c7b1-fe3d-40c0-ab1d-c9dee9ab7c07?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/3364c7b1-fe3d-40c0-ab1d-c9dee9ab7c07?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/3364c7b1-fe3d-40c0-ab1d-c9dee9ab7c07?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/3364c7b1-fe3d-40c0-ab1d-c9dee9ab7c07?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/3364c7b1-fe3d-40c0-ab1d-c9dee9ab7c07?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=Here%20are%20the%20files%20and%20code%20sections%20you%20need%20to%20customize%20export%20filenames%20in%20Superset%3A%0A%0A%2A%2A1.%20Chart%20exports%20%28CSV/XLSX/ZIP%29%3A%2A%2A%0A-%20File%3A%20%60superset/charts/data/api.py%60%0A-%20Method%3A%20%60_send_chart_response%60%0A-%20By%20default%2C%20this%20method%20calls%20%60generate_download_headers%28%22csv%22%29%60%20%28or%20%60%22xlsx%22%60%2C%20%60%22zip%22%60%29%20with%20no%20filename%2C%20so%20you%20get%20a%20timestamp-based%20name.%20%20%0A-%20To%20use%20the%20chart%20name%20and%20ID%2C%20modify%20the%20call%20like%3A%0A%20%20%60%60%60python%0A%20%20from%20werkzeug.utils%20import%20secure_filename%0A%20%20chart_name%20%3D%20secure_filename%28result%5B%22query_context%22%5D.form_data.get%28%
 22slice_name%22%2C%20%22chart%22%29%29%0A%20%20chart_id%20%3D%20result%5B%22query_context%22%5D.form_data.get%28%22slice_id%22%2C%20%22id%22%29%0A%20%20filename%20%3D%20f%22%7Bchart_name%7D_%7Bchart_id%7D%22%0A%20%20headers%20%3D%20generate_download_headers%28%22csv%22%2C%20filename%29%0A%20%20%60%60%60%0A%20%20Do%20similar%20for%20XLSX%20and%20ZIP%20exports.%20%20%0A%20%20%5BReference%5D%28https%3A//github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/superset/charts/data/api.py%23L346-L411%29%0A%0A%2A%2A2.%20Dashboard%20exports%20%28YAML%20ZIP%29%3A%2A%2A%0A-%20File%3A%20%60superset/dashboards/api.py%60%0A-%20Method%3A%20%60export%60%0A-%20The%20ZIP%20filename%20is%20set%20by%3A%0A%20%20%60%60%60python%0A%20%20timestamp%20%3D%20datetime.now%28%29.strftime%28%22%25Y%25m%25dT%25H%25M%25S%22%29%0A%20%20root%20%3D%20f%22dashboard_export_%7Btimestamp%7D%22%0A%20%20filename%20%3D%20f%22%7Broot%7D.zip%22%0A%20%20%60%60%60%0A-%20Change%20this%20to%20use%20dashboard%20t
 itles%20and%20IDs.%20For%20example%3A%0A%20%20%60%60%60python%0A%20%20from%20superset.utils.file%20import%20get_filename%0A%20%20dashboards%20%3D%20%5BDashboardDAO.find_by_id%28did%29%20for%20did%20in%20requested_ids%5D%0A%20%20name_tokens%20%3D%20%5Bget_filename%28d.dashboard_title%2C%20d.id%29%20for%20d%20in%20dashboards%20if%20d%5D%0A%20%20root%20%3D%20%22_%22.join%28name_tokens%29%0A%20%20filename%20%3D%20f%22%7Broot%7D.zip%22%0A%20%20%60%60%60%0A%20%20%5BReference%5D%28https%3A//github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/superset/dashboards/api.py%23L1002-L1023%29%0A%0A%2A%2A3.%20Download%20header%20helper%3A%2A%2A%0A-%20File%3A%20%60superset/views/base.py%60%0A-%20Function%3A%20%60generate_download_headers%60%0A-%20This%20function%20just%20takes%20your%20filename%20and%20extension%20and%20sets%20the%20HTTP%20header.%20It%20does%20not%20sanitize%20or%20deduplicate%2C%20so%20do%20that%20before%20calling%20it.%0A%20%20%5BReference%5D%28https%3A//gith
 ub.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/superset/views/base.py%23L141-L147%29%0A%0A%2A%2AChecklist%3A%2A%2A%0A-%20Extract%20chart/dashboard%20name%20and%20ID/UUID%20in%20the%20export%20method.%0A-%20Sanitize%20the%20name%20%28use%20%60secure_filename%60%20or%20similar%29.%0A-%20Pass%20the%20sanitized%20filename%20to%20%60generate_download_headers%60%20%28charts%29%20or%20as%20%60download_name%60%20in%20%60send_file%60%20%28dashboards%29.%0A-%20Test%20with%20special%20characters%20and%20non-ASCII%20names.%0A%0ALet%20me%20know%20if%20you%20need%20a%20more%20detailed%20code%20sample%20for%20a%20specific%20export%20type.)&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=%40dosu_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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org