AmoghAtreya opened a new pull request, #42541:
URL: https://github.com/apache/superset/pull/42541

   # fix(export): truncate exported filenames to prevent Windows path 
extraction errors (#42531)
   
   ### SUMMARY
   Fixes **#42531** by capping exported filenames generated via 
`get_filename()` in `superset/utils/file.py` to a maximum component length 
(`MAX_FILENAME_LENGTH = 128`).
   
   When assets (charts, dashboards, datasets) have long titles (~250+ 
characters), exported YAML files inside the ZIP archive exceed Windows 
`MAX_PATH` limits (260 characters) upon extraction. This fix caps individual 
filename components while leaving ample buffer for extraction destination paths.
   
   Key details:
   - Caps individual filename components to `MAX_FILENAME_LENGTH = 128`.
   - Replaces negative slicing risks with `max_slug_length = max(max_length - 
len(id_suffix), 0)` to guarantee safe truncation and clean fallbacks to 
`str(model_id)`.
   - Strips trailing dots, hyphens, and underscores (`.-_`) created during 
truncation to prevent invalid trailing periods in Windows filenames.
   - Expanded unit test coverage in `tests/unit_tests/utils/test_file.py` from 
29 to 92 tests, incorporating property-based path assertions, edge cases 
(extreme lengths, trailing delimiters, non-ASCII input, boundary conditions, 
and suffix preservation), and mutation-tested invariants.
   
   ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   *N/A — backend export filename generation.*
   
   ### TESTING INSTRUCTIONS
   1. Run unit tests:
      ```bash
      pytest tests/unit_tests/utils/test_file.py
   2. Export a chart, dashboard, or dataset with a name over 200 characters 
long.
   3. Extract the generated ZIP archive on a Windows system to verify 
extraction completes without path length errors.
   
   ### ADDITIONAL INFORMATION
   <!--- Check any relevant boxes with "x" -->
   <!--- HINT: Include "Fixes #nnn" if you are fixing an existing issue -->
   - [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
   


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