danny-avila/LibreChat · warning · Error

Extracted text from "${file.originalname}" exceeds the 15MB

Error message

Extracted text from "${file.originalname}" exceeds the 15MB storage limit (${Math.round(textBytes / megabyte)}MB). Try a shorter document.

What it means

Thrown by the inner createTextFile helper when the UTF-8 byte length of extracted text (from OCR, RAG, STT, or document parsing) exceeds 15 MB. This is a hard storage cap on extracted text persisted to the file/text field; it prevents one giant document from blowing up the DB row or downstream token budgets. The original filename and the computed MB are included.

Source

Thrown at api/server/services/Files/process.js:758

    if (!isFileSearchEnabled) {
      throw new Error('File search is not enabled for Agents');
    }
    // Note: File search processing continues to dual storage logic below
  } else if (tool_resource === EToolResources.context) {
    const { file_id, temp_file_id = null } = metadata;

    /**
     * @param {object} params
     * @param {string} params.text
     * @param {number} params.bytes
     * @param {string} params.filepath
     * @param {string} params.type
     * @return {Promise<void>}
     */
    const createTextFile = async ({ text, bytes, filepath, type = 'text/plain' }) => {
      const textBytes = Buffer.byteLength(text, 'utf8');
      if (textBytes > 15 * megabyte) {
        throw new Error(
          `Extracted text from "${file.originalname}" exceeds the 15MB storage limit (${Math.round(textBytes / megabyte)}MB). Try a shorter document.`,
        );
      }
      const retentionExpiry = await getAgentFileRetentionExpiry({
        req,
        messageAttachment,
        tool_resource,
      });
      const fileInfo = {
        ...removeNullishValues({
          text,
          bytes,
          file_id,
          temp_file_id,
          user: req.user.id,
          type,
          filepath: filepath ?? file.path,
          source: FileSources.text,

View on GitHub (pinned to 5ff282f900)

Solutions

  1. Upload a shorter document — split the source PDF into chunks under the limit.
  2. For long audio, trim or segment before STT so the transcript stays under 15 MB.
  3. If extraction is producing inflated/garbage text, investigate the OCR/RAG parser — duplicated output suggests a parser bug.
  4. Do not raise the 15 MB constant casually; it also bounds DB row size and downstream LLM token cost.
Defensive patterns

Strategy: validation

Validate before calling

const TEXT_LIMIT = 15 * 1024 * 1024;
function assertExtractedTextSize(text, filename) {
  const bytes = Buffer.byteLength(text, 'utf8');
  if (bytes > TEXT_LIMIT) {
    throw new Error(`Extracted text from ${filename} is ${Math.round(bytes / (1024*1024))}MB; limit is 15MB`);
  }
}

Try / catch

try { await processAgentFileUpload(params); }
catch (e) {
  if (/exceeds the 15MB storage limit/.test(e.message)) return res.status(413).json({ error: 'Document too large to index; please split it.' });
  throw e;
}

Prevention

When it happens

Trigger: A document whose extracted text crosses 15 MB — e.g., a 2,000-page PDF, a large transcribed audio file, or an OCR'd scan of a book. The text length is computed via `Buffer.byteLength(text, 'utf8')`, not the source file size.

Common situations: Users uploading entire books or massive reports; OCR of a high-page-count scan; a long webinar's STT output; a malformed text extractor that emits duplicated/garbage text inflating byte count.

Related errors


AI-assisted analysis of danny-avila/LibreChat@5ff282f900 (2026-08-12). Data as JSON: /api/errors/bef3f0fb75548c4a. Report an issue: GitHub.