LibreChat/api/server/routes
Danny Avila 5e464bc930
📎 fix: Alias Shell Script MIME Variants to application/x-sh (#14817)
* 📎 fix: Alias Shell Script MIME Variants to `application/x-sh`

Chrome on Linux reports `.sh` files as `application/x-shellscript`
(freedesktop shared-mime-info) and libmagic reports `text/x-shellscript`.
Neither string appears anywhere in the source, so uploads were rejected
even though `application/x-sh` is in the default allowlist and
`codeTypeMapping` maps `sh` to it — `inferMimeType` only consults the
extension map when the client sends no type at all, so a non-empty
browser value passed straight through to the allowlist check.

Alias both variants to the canonical `application/x-sh`, matching the
existing treatment of `text/x-markdown` and `application/x-zip-compressed`.

Also attach `statusCode`/`body` to multer file-filter rejections. Without
them the error misses the `isCustomError` branch in `ErrorController` and
falls through to a bare `500 An unknown error occurred.`, so the rejection
reason was logged server-side but never reached the client. The upload
hook already surfaces `error.response.data.message`, so a rejected file
now explains itself instead of showing a generic upload failure.

* 🔁 refactor: Move Upload Error Contract Into `packages/api`

Addresses codex P1 on #14817.

The producer of the `statusCode`/`body` pair now sits beside its consumer:
`isCustomError` and `ErrorController` are already in
`packages/api/src/middleware/error.ts`, and `CustomError` is already in
`packages/api/src/types/error.ts` — only the construction of that pair was
stranded in legacy JS. `createCustomError` is exported from the same module
as the guard that recognizes it, and `multer.js` is back to a thin caller.

Also pins the `.sh` back-compat claim with tests: configs from the
documented workarounds (`application/x-sh` per #4660/#5689/#6297, and the
broad patterns from #14804) still accept a `.sh` upload after the alias
rewrites the type. A negative control confirms the endpoint config is
genuinely in play rather than falling back to the default allowlist.
2026-08-14 01:12:23 -04:00
..
__test-utils__
__tests__ 💬 style: Unify Message Row Layout and Edit Surfaces (#14770) 2026-08-13 19:30:39 -04:00
admin 🪢 feat: add Langfuse session links (#14776) 2026-08-12 22:25:23 -04:00
agents 🧷 fix: Preserve Elicitation Answers Across Aborts (#14745) 2026-08-12 07:32:48 -04:00
assistants
files 📎 fix: Alias Shell Script MIME Variants to application/x-sh (#14817) 2026-08-14 01:12:23 -04:00
types
accessPermissions.js
accessPermissions.sharePolicy.test.js
accessPermissions.test.js
actions.js
apiKeys.js
auth.2fa-ratelimit.test.js
auth.cloudfront.test.js
auth.js
auth.reset-password-ratelimit.test.js
balance.js
banner.js
categories.js
config.js 🔗 feat: Admin Panel Link in Settings for Admins (#14662) 2026-08-06 12:40:44 -04:00
convos.js 🔗 feat: Shared Conversation Badge and Stable Share Links (#14712) 2026-08-09 08:14:54 -04:00
endpoints.js
index.js 🪢 feat: Langfuse Fanout Connection Setting (#14108) 2026-07-29 18:33:10 -04:00
keys.js
mcp.js 🛰️ fix: Attach Request-Scoped MCP Servers (#14780) 2026-08-12 23:43:02 -04:00
memories.js 🗂️ feat: Per-Agent Memory Partitions (#14084) 2026-07-09 10:48:51 -04:00
messages.js 💬 style: Unify Message Row Layout and Edit Surfaces (#14770) 2026-08-13 19:30:39 -04:00
models.js
oauth.js
oauth.test.js
presets.js
projects.js
prompts.js
prompts.test.js
roles.js
rum.js
search.js
settings.js
share.js 🔗 feat: Shared Conversation Badge and Stable Share Links (#14712) 2026-08-09 08:14:54 -04:00
skills.js 🪆 fix: Serve Nested Skill Files Through a Wildcard Route (#14191) 2026-07-09 16:52:11 -04:00
skills.tenant.test.js
skills.test.js 🛟 fix: Isolate Invalid Skills During GitHub Sync (#14735) 2026-08-12 13:22:06 -04:00
static.js
tags.js
user.js
user.verify-ratelimit.test.js