Skip to content

fix(codeapi): add UTF-8 charset defaults to busboy in upload routes - #65

Open
chottokun wants to merge 1 commit into
LibreChat-AI:mainfrom
chottokun:fix/utf8-charset-busboy-upload
Open

fix(codeapi): add UTF-8 charset defaults to busboy in upload routes#65
chottokun wants to merge 1 commit into
LibreChat-AI:mainfrom
chottokun:fix/utf8-charset-busboy-upload

Conversation

@chottokun

Copy link
Copy Markdown

Problem

Non-ASCII filenames (e.g. Japanese characters like 日本語テスト.md) uploaded
through the /upload and /upload/batch endpoints are garbled because
busboy defaults to Latin-1 (ISO-8859-1) for parameter charset decoding.

For example, 日本語 becomes 日本語.

Root Cause

The file-server.ts already sets defCharset: 'utf8' and
defParamCharset: 'utf8' when constructing busboy (line 336-337), but
the same options are missing from the two busboy() calls in router.ts:

This asymmetry causes filenames to be correctly decoded in the file-server
path but garbled in the API gateway upload path.

Fix

Add defCharset: 'utf8' and defParamCharset: 'utf8' to both busboy()
calls in router.ts, consistent with the existing file-server.ts configuration.

Testing

Verified by uploading files with Japanese filenames (e.g. Github_Code_Reviewer_日本語_-saved.md)
through the /upload endpoint and confirming the filename is correctly preserved without garbling.

Changes

  • service/src/service/router.ts: Added defCharset: 'utf8' and defParamCharset: 'utf8' to 2 busboy constructor calls

The /upload and /upload/batch endpoints in router.ts construct busboy
without specifying defCharset or defParamCharset. Busboy defaults to
Latin-1 (ISO-8859-1) for multipart parameter decoding, which causes
non-ASCII filenames (e.g. Japanese characters) to be garbled.

file-server.ts already sets defCharset: 'utf8' and
defParamCharset: 'utf8' (lines 336-337), but router.ts was missing
the same options — an asymmetry that surfaces as mojibake when
uploading files with non-ASCII names through the API gateway.

Add both options to the two busboy() calls in router.ts for
consistency with file-server.ts.
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.

1 participant