{"record":{"id":"bef3f0fb75548c4a","repo":"danny-avila/LibreChat","slug":"extracted-text-from-file-originalname-exceeds","errorCode":null,"errorMessage":"Extracted text from \"${file.originalname}\" exceeds the 15MB storage limit (${Math.round(textBytes / megabyte)}MB). Try a shorter document.","messagePattern":"Extracted text from \"(.+?)\" exceeds the 15MB storage limit \\((.+?)MB\\)\\. Try a shorter document\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"api/server/services/Files/process.js","lineNumber":758,"sourceCode":"    if (!isFileSearchEnabled) {\n      throw new Error('File search is not enabled for Agents');\n    }\n    // Note: File search processing continues to dual storage logic below\n  } else if (tool_resource === EToolResources.context) {\n    const { file_id, temp_file_id = null } = metadata;\n\n    /**\n     * @param {object} params\n     * @param {string} params.text\n     * @param {number} params.bytes\n     * @param {string} params.filepath\n     * @param {string} params.type\n     * @return {Promise<void>}\n     */\n    const createTextFile = async ({ text, bytes, filepath, type = 'text/plain' }) => {\n      const textBytes = Buffer.byteLength(text, 'utf8');\n      if (textBytes > 15 * megabyte) {\n        throw new Error(\n          `Extracted text from \"${file.originalname}\" exceeds the 15MB storage limit (${Math.round(textBytes / megabyte)}MB). Try a shorter document.`,\n        );\n      }\n      const retentionExpiry = await getAgentFileRetentionExpiry({\n        req,\n        messageAttachment,\n        tool_resource,\n      });\n      const fileInfo = {\n        ...removeNullishValues({\n          text,\n          bytes,\n          file_id,\n          temp_file_id,\n          user: req.user.id,\n          type,\n          filepath: filepath ?? file.path,\n          source: FileSources.text,","sourceCodeStart":740,"sourceCodeEnd":776,"githubUrl":"https://github.com/danny-avila/LibreChat/blob/5ff282f9006c436e561de1afd39a481bea1ef0d8/api/server/services/Files/process.js#L740-L776","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Upload a shorter document — split the source PDF into chunks under the limit.","For long audio, trim or segment before STT so the transcript stays under 15 MB.","If extraction is producing inflated/garbage text, investigate the OCR/RAG parser — duplicated output suggests a parser bug.","Do not raise the 15 MB constant casually; it also bounds DB row size and downstream LLM token cost."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"const TEXT_LIMIT = 15 * 1024 * 1024;\nfunction assertExtractedTextSize(text, filename) {\n  const bytes = Buffer.byteLength(text, 'utf8');\n  if (bytes > TEXT_LIMIT) {\n    throw new Error(`Extracted text from ${filename} is ${Math.round(bytes / (1024*1024))}MB; limit is 15MB`);\n  }\n}","typeGuard":null,"tryCatchPattern":"try { await processAgentFileUpload(params); }\ncatch (e) {\n  if (/exceeds the 15MB storage limit/.test(e.message)) return res.status(413).json({ error: 'Document too large to index; please split it.' });\n  throw e;\n}","preventionTips":["Split large documents (books, long reports) into sub-15 MB chunks before upload.","For long audio, segment before STT to bound transcript size.","Investigate inflated/garbage text from OCR/RAG — duplication suggests a parser bug."],"tags":["text-extraction","size-limit","storage","document"],"backgroundTag":null,"analyzedSha":"5ff282f9006c436e561de1afd39a481bea1ef0d8","analyzedAt":"2026-08-12T21:38:08.145Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}