Skip to content

fix: sanitize uploaded filenames before storage to match LibreChat#32

Merged
aron-muon merged 1 commit intoaron-muon:mainfrom
wipash:filename_fix
Feb 9, 2026
Merged

fix: sanitize uploaded filenames before storage to match LibreChat#32
aron-muon merged 1 commit intoaron-muon:mainfrom
wipash:filename_fix

Conversation

@wipash
Copy link
Contributor

@wipash wipash commented Feb 9, 2026

Summary

When files are uploaded via LibreChat, LibreChat sanitizes filenames (replacing spaces and special characters with underscores) before telling the model about them. However, KCR was storing files with the original unsanitized filename. This meant the model would try to open my_file.csv but the file on disk in the pod was actually my file.csv, causing the first execution to fail. The model would then have to list the directory, discover the real name, and retry.

This fix moves filename sanitization to happen before storage, so the name on disk matches what LibreChat reports.

Type of change

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

  • Added parametrized unit tests covering filenames with spaces, parentheses, &, #, !@#$, and unicode characters
  • All 33 unit tests pass locally

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

LibreChat translates spaces and special characters in filenames to
underscores, but KCR was storing the original unsanitized name. This
caused the model to fail on first file access since the name on disk
didn't match what LibreChat reported.
@wipash wipash requested a review from aron-muon as a code owner February 9, 2026 02:47
@aron-muon aron-muon merged commit 53e445d into aron-muon:main Feb 9, 2026
28 checks passed
@github-actions
Copy link

github-actions bot commented Feb 9, 2026

🎉 This PR is included in version 2.1.3 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

@wipash wipash deleted the filename_fix branch February 9, 2026 21:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants