LibreChat/api/server
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
..
controllers 🩹 fix: Restore the @librechat/api Build and Remove Legacy Code (#14808) 2026-08-13 19:57:32 -04:00
middleware 🍡 feat: Batched User Questions With A Single Bounded Answer Form (#14737) 2026-08-11 01:06:16 -04:00
routes 📎 fix: Alias Shell Script MIME Variants to application/x-sh (#14817) 2026-08-14 01:12:23 -04:00
services 🛰️ fix: Attach Request-Scoped MCP Servers (#14780) 2026-08-12 23:43:02 -04:00
utils 🔗 feat: Shared Conversation Badge and Stable Share Links (#14712) 2026-08-09 08:14:54 -04:00
cleanup.js
experimental.js 🫆 chore: Remove Published Credential Defaults (#14680) 2026-08-07 07:25:05 -04:00
experimental.spec.js 🫆 chore: Remove Published Credential Defaults (#14680) 2026-08-07 07:25:05 -04:00
index.js 🪝 feat: Execute Agent Plugin Command Hooks (#14755) 2026-08-12 13:21:15 -04:00
index.metrics.spec.js test(mcp): mock static tool startup sync (#14711) 2026-08-08 23:12:07 -04:00
index.spec.js 🧭 fix: Make MCP Catalog Redis Cluster-Safe (#14717) 2026-08-09 06:59:29 -04:00
socialLogins.js
socialLogins.spec.js
telemetry.js
telemetry.spec.js