﻿# LibreChat MIME restrictions use validated RE2-compatible patterns

Validate LibreChat MIME patterns using the documented server engine and distinguish upload permission from OCR selection and delivery to the model.

Author: Retrivium editorial team
Updated: 2026-11-03
Canonical URL: https://retrivium.ai/journal/guide-librechat-mime-pattern-validation/
Language: en

## Separate admission from processing

A workspace accepts a PDF but cannot answer a question about its scan. The upload rule and the reading path govern different stages. First establish whether the file type was admitted, then identify whether the file was delivered natively, extracted as text, or retained for a tool. A successful first stage does not establish the others.

## Validate the actual pattern language

The [file configuration reference](https://www.librechat.ai/docs/configuration/librechat_yaml/object_structure/file_config) says MIME patterns are compiled by a server-side linear-time regex engine and unsupported constructs such as lookaround or backreferences reject configuration. Do not copy a pattern from a different regex dialect without validation. A rule that looks familiar can fail before any upload is processed.

## Match reported types deliberately

The same reference describes normalization of common MIME aliases before matching. Inspect the unsupported type reported by a rejected upload instead of relying only on its filename extension. A shell script or a document exported by another tool can arrive with a different reported media type while still representing the expected material.

For a document workflow, maintain examples of permitted and excluded types and their expected stage outcomes. An admission check should answer whether the upload is allowed; a separate processing check should establish whether the selected path can extract useful content from that particular file.

## Keep OCR selection independent

The [OCR reference](https://www.librechat.ai/docs/configuration/librechat_yaml/object_structure/ocr) distinguishes service configuration, agent capability, and type selection. Adding a type to an OCR-related list does not itself activate a service. Conversely, a native provider attachment can follow another path even when an OCR service exists for text extraction elsewhere in the deployment.

## Check what reaches the model

[Upload Files as Text](https://www.librechat.ai/docs/features/upload_as_text) describes current automatic delivery and older explicit destination choices. Record the route actually used when testing a file. A broad MIME allowlist should not become an unexplained promise that every accepted binary format has a working parser or yields the complete text needed for the question.

The existing guides to [response contracts](/journal/learn-openrouter-response-contract/) and [tool observations](/journal/learn-codex-tool-observation/) help structure that distinction. Keep pattern validation, admission, extraction, and model input as separate observed outcomes so an operator can correct the relevant rule without changing unrelated stages.
