Skip to content

Conversation

@beveradb
Copy link
Collaborator

Summary

  • Fixes download failures for songs with non-ASCII characters (Vietnamese, Japanese, Korean, Chinese, etc.)
  • The audio-separator API now properly encodes Unicode filenames in HTTP Content-Disposition headers using RFC 5987

Problem

When downloading separated audio files with Unicode filenames like Việt Nhân - Sầu Thương_(Vocals).flac, the download endpoint failed with:

'latin-1' codec can't encode character '\u1ec7' in position 23: ordinal not in range(256)

This affected any song with non-ASCII characters in artist name or title.

Solution

Updated the /download/{task_id}/{file_hash} endpoint to use RFC 5987 encoding:

# ASCII fallback for older clients
ascii_filename = "".join(c if ord(c) < 128 else "_" for c in actual_filename)
# UTF-8 encoded filename for modern clients
encoded_filename = quote(actual_filename, safe="")
content_disposition = f'attachment; filename="{ascii_filename}"; filename*=UTF-8\'\'{encoded_filename}'

Test plan

  • All 204 unit/contract tests pass
  • Verified encoding produces HTTP-compliant headers (can be encoded as latin-1)
  • Verified Vietnamese filename "Việt Nhân - Sầu Thương" encodes correctly
  • Deploy to Modal and test with real Unicode filename

@coderabbitai ignore

🤖 Generated with Claude Code

beveradb and others added 2 commits January 23, 2026 23:05
…eader

Fixes download failures for songs with non-ASCII characters (Vietnamese,
Japanese, Korean, etc.) by properly encoding the Content-Disposition header.

The issue occurred when downloading separated audio files with Unicode
filenames like "Việt Nhân - Sầu Thương_(Vocals).flac" - the HTTP header
encoding failed with "'latin-1' codec can't encode character".

Solution:
- Add ASCII fallback filename for older clients
- Add RFC 5987 filename*=UTF-8'' parameter for modern clients
- Both parameters in the header ensure broad compatibility

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@beveradb beveradb enabled auto-merge (squash) January 24, 2026 07:34
@beveradb beveradb merged commit 8b193be into main Jan 24, 2026
18 checks passed
@beveradb beveradb deleted the feat/sess-20260123-2252-fix-unicode-content-disposition branch January 24, 2026 08:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants