Skip to content

fix(upload): decode multipart filenames as UTF-8 - #36

Closed
Massimo314 wants to merge 1 commit into
LibreChat-AI:mainfrom
Massimo314:fix/upload-filename-utf8
Closed

fix(upload): decode multipart filenames as UTF-8#36
Massimo314 wants to merge 1 commit into
LibreChat-AI:mainfrom
Massimo314:fix/upload-filename-utf8

Conversation

@Massimo314

Copy link
Copy Markdown

Fixes #35

Problem

POST /upload and POST /upload/batch lose non-ASCII filenames. The name
reaches the sandbox /mnt/data as UTF-8-bytes-decoded-as-Latin-1 mojibake —
e.g. Расчет_иска.docxРаÑÑеÑ_иÑка.docx. As noted in #35 this
also affects Japanese filenames.

Root cause

Both busboy instances in service/src/service/router.ts were constructed
without defParamCharset, so busboy 1.x fell back to its latin1 default and
decoded the multipart Content-Disposition filename bytes as Latin-1. Clients
(e.g. LibreChat via form-data) send the filename as raw UTF-8 bytes, the
de-facto browser behavior.

The sibling handler service/src/file-server.ts (POST /sessions/:id/objects)
already sets defParamCharset: 'utf8' — this change brings the two upload
routes in line with it.

Fix

Add defParamCharset: 'utf8' to the /upload and /upload/batch busboy
options.

Verification

  • Isolated repro (busboy@1.6.0, form-data@4.0.6): the latin1 default reproduces
    the exact mojibake; defParamCharset: 'utf8' yields the correct name.
  • Rebuilt and deployed to a production stack — Cyrillic filenames now arrive
    intact in /mnt/data.

@CLAassistant

CLAassistant commented Jul 29, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

The /upload and /upload/batch busboy instances omitted defParamCharset,
so busboy 1.x used its latin1 default and mangled non-ASCII filenames
(e.g. "Расчет_иска.docx" -> "РаÑÑеÑ_иÑка.docx"; also affects
Japanese names). Clients send raw UTF-8 filename bytes in
Content-Disposition, matching the sibling file-server.ts handler which
already sets defParamCharset: 'utf8'.

Verified on a production deployment.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@Massimo314
Massimo314 force-pushed the fix/upload-filename-utf8 branch from 4c94b92 to 3035592 Compare July 29, 2026 16:33
@danny-avila

Copy link
Copy Markdown
Collaborator

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 2, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-02T02:38:22.738142Z 3035592 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Hooray!

Reviewed commit: 30355920ef

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@danny-avila danny-avila closed this Sep 2, 2026
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.

Non-ASCII upload filenames become mojibake — /upload busboy missing defParamCharset: 'utf8'

3 participants