Skip to content

fix: skip unsupported files in a batch instead of rejecting the whole upload - #16801

Open
dai123x wants to merge 1 commit into
LibreChat-AI:devfrom
dai123x:fix/skip-unsupported-files-in-batch
Open

dai123x wants to merge 1 commit into
LibreChat-AI:devfrom
dai123x:fix/skip-unsupported-files-in-batch

Conversation

@dai123x

@dai123x dai123x commented Oct 5, 2026

Copy link
Copy Markdown

Summary

Dropping several files at once where one has an unsupported type rejects the entire selection: validateFiles bails out with Unsupported file type: … on the first offender, so a drop of photo.png + notes.txt + setup.exe attaches nothing and the supported files have to be picked again one by one (reported with a recording in #16659). #15358 already made duplicates and oversized files drop out of a selection one by one while the rest uploads; unsupported types were left all-or-nothing. This change moves the per-file MIME check into that same partition step, so the supported files attach and a toast names the skipped ones: "Skipped unsupported file(s): setup.exe".

Fixes #16659

How it works

selection
  partitionUploads          # per-file rules: duplicate → fileSize → type (inference + allowlist)
    survivors → validateFiles       # unchanged; still the safety net plus batch rules
    skipped   → reportSkippedUploads  # per-file skip toasts

partitionUploads now screens each file's type alongside duplicate and size: it infers the MIME type, re-types the file in fileList in place exactly as validateFiles does, and skips files the allowlist rejects with a new unsupported skip reason. The allowlist choice — the endpoint's own list, or the configured text/OCR/STT lists for context tool resources — moved into a shared getMimeTypesToCheck helper so the partition and validation paths cannot drift, and both processFiles partition calls (pre- and post-processing, the latter after HEIC conversion and resize) pass fileConfig and toolResource through. validateFiles keeps its type loop unchanged: when the partition keeps nothing, the untouched selection still goes through the usual all-or-nothing checks and reports the pre-existing "Unsupported file type: …" error, and the loop remains the guard for callers that do not partition.

Type of change

  • Bug fix

Testing

Tested environments/configuration:

  • OS: Windows 11, Node v24.17; the verification below is the client unit suites (jsdom via jest).

Automated tests:

  • Added partition cases in client/src/utils/__tests__/validateFiles.spec.ts: an unsupported file skipped while the files picked alongside it are kept, a fully unsupported selection, inference re-typing, an undeterminable type, and the context tool-resource allowlist.
  • Added hook cases in client/src/hooks/Files/__tests__/useFileHandling.test.ts: a batch of photo.png + setup.exe uploads the png and reports com_error_files_skipped_unsupported, while a fully unsupported batch is still rejected in full with the pre-existing error and no skip notice.
  • npx jest src/utils/__tests__/validateFiles.spec.ts src/hooks/Files/__tests__/useFileHandling.test.ts — 93 passing (32 + 61); the wider src/hooks/Files + src/utils suites pass except pre-existing locale-dependent formatCost expectations in tokens.spec.ts ($ vs US$, unrelated to this change).

Screenshots / recordings

No screenshot: no visual component changed. The only visible difference is the skip toast, which reuses the same error-toast mechanism as the existing duplicate and size skip notices ("Skipped duplicate file(s): …", "Skipped file(s) over the {{0}} MB size limit: …"), and the suites above assert the new com_error_files_skipped_unsupported key.

Risk / compatibility

Low. The only behavior change is on the upload-selection path (processFiles), and only when a selection contains a file the endpoint cannot accept: previously everything was rejected, now the unsupported file is skipped and the rest uploads. A selection where nothing survives is still rejected in full with the same messages as before. Server-side validation is untouched — the client merely stops sending files the server would have rejected anyway.

Checklist

  • I reviewed my own changes
  • Relevant tests have been added or updated
  • Existing relevant tests pass
  • The change does not introduce new warnings or errors
  • User-facing or complex behavior is documented where necessary (N/A — no documentation change needed)
  • Required dependency changes have been merged/published (N/A)
  • Required documentation PR: N/A

@codegraph-librechat codegraph-librechat Bot added the 🗺️ Chat Frontend codegraph: the taxonomy area this belongs to (classifier, confidence ≥ 0.9) label Oct 6, 2026
@dai123x

dai123x commented Oct 9, 2026

Copy link
Copy Markdown
Author

Friendly ping — none of the workflows have run on the current head (0abcac82); all seven are sitting at action_required:

  • Static Checks
  • Frontend Unit Tests
  • Playwright E2E Tests
  • Lighthouse CI
  • Docker Build Smoke Tests
  • Bombadil Property Exploration
  • Codegraph Select (observe)

Could a maintainer approve the runs and take a look? The change reuses the existing per-file drop behaviour added in #15358 and only extends it to unsupported MIME types, so dropping photo.png + notes.txt + setup.exe now attaches the two supported files instead of rejecting the whole selection. Closes #16659.

Happy to rework the approach if you would rather handle it differently.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🗺️ Chat Frontend codegraph: the taxonomy area this belongs to (classifier, confidence ≥ 0.9)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant