bikash-barnwal opened a new pull request, #43188:
URL: https://github.com/apache/superset/pull/43188

   ### SUMMARY
   
   Exporting a chart whose title is a couple of hundred characters long 
produces a ZIP that Windows cannot extract. The archive itself is written fine 
— which is why the export appears to succeed and only fails at unzip time.
   
   `get_filename` (`superset/utils/file.py`) builds `{slug}_{id}` from the full 
asset title with no length limit:
   
   ```python
   slug = secure_filename(model_name)
   filename = slug if skip_id else f"{slug}_{model_id}"
   ```
   
   The resulting name goes into a ZIP entry that already carries an 
`<asset>_export_<timestamp>/<type>/` prefix and a `.yaml` suffix, with the 
user's own extraction directory in front of all of it.
   
   This caps the name at 200 characters — comfortably under the 255-character 
limit a single path component has — leaving room for the directories and 
extension wrapped around it. The **slug** is trimmed, never the id: the id is 
what stops two similarly titled assets colliding inside one archive. Any 
separator left dangling at the cut (`.`, `_`, `-`) is stripped so the name 
doesn't run straight into the extension.
   
   `get_filename` is the single chokepoint for chart, dashboard, database, 
dataset and theme exports, so one fix covers all of them.
   
   ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   
   For a 250-character chart title, entry name inside the archive:
   
   | | length |
   |---|---|
   | before | 254 (+ prefix and `.yaml`) → extraction fails on Windows |
   | after | 200, ending in `_132` |
   
   ### TESTING INSTRUCTIONS
   
   ```bash
   pytest tests/unit_tests/utils/test_file.py
   pytest tests/unit_tests/commands -k export
   ```
   
   New cases cover the cap with and without the id, that the id survives 
truncation, that no separator is left trailing, and that short names are 
untouched. Locally: **27 passed** in `test_file.py` (was 22) and **70 passed** 
across the export command tests.
   
   Note for reviewers: `test_get_filename[D:\Charts\Energy Sankey-...]` fails 
on a Windows dev machine both before and after this change — `secure_filename` 
treats `\` as a path separator there but not on Linux — so it is 
platform-dependent and untouched here.
   
   Manually: name a chart ~250 characters, export it, and extract the ZIP on 
Windows.
   
   ### ADDITIONAL INFORMATION
   
   - [x] Has associated issue: Fixes #42531
   - [ ] Required feature flags:
   - [ ] Changes UI
   - [ ] Includes DB Migration (follow approval process in 
[SIP-59](https://github.com/apache/superset/issues/13351))
     - [ ] Migration is atomic, supports rollback & is backwards-compatible
     - [ ] Confirm DB migration upgrade and downgrade tested
     - [ ] Runtime estimates and downtime expectations provided
   - [ ] Introduces new feature or API
   - [ ] Removes existing feature or API
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)


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