{"record":{"id":"157388dd03d00f1f","repo":"danny-avila/LibreChat","slug":"file-embedding-failed-the-filetype-file-mimetyp","errorCode":null,"errorMessage":"File embedding failed. The filetype ${file.mimetype} is not supported","messagePattern":"File embedding failed\\. The filetype (.+?) is not supported","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"api/server/services/Files/VectorDB/crud.js","lineNumber":100,"sourceCode":"    if (storageMetadata) {\n      formData.append('storage_metadata', JSON.stringify(storageMetadata));\n    }\n\n    const formHeaders = formData.getHeaders();\n\n    const response = await axios.post(`${process.env.RAG_API_URL}/embed`, formData, {\n      headers: {\n        Authorization: `Bearer ${jwtToken}`,\n        accept: 'application/json',\n        ...formHeaders,\n      },\n    });\n\n    const responseData = response.data;\n    logger.debug('Response from embedding file', responseData);\n\n    if (responseData.known_type === false) {\n      throw new Error(`File embedding failed. The filetype ${file.mimetype} is not supported`);\n    }\n\n    if (!responseData.status) {\n      throw new Error('File embedding failed.');\n    }\n\n    return {\n      bytes: file.size,\n      filename: file.originalname,\n      filepath: FileSources.vectordb,\n      embedded: Boolean(responseData.known_type),\n    };\n  } catch (error) {\n    logAxiosError({\n      error,\n      message: 'Error uploading vectors',\n    });\n    throw new Error(error.message || 'An error occurred during file upload.');","sourceCodeStart":82,"sourceCodeEnd":118,"githubUrl":"https://github.com/danny-avila/LibreChat/blob/5ff282f9006c436e561de1afd39a481bea1ef0d8/api/server/services/Files/VectorDB/crud.js#L82-L118","documentation":"Thrown by uploadVectors when the RAG API's /embed endpoint responds successfully (HTTP 200) but the response body contains known_type: false, meaning the file's MIME type is not supported for embedding. The RAG API parsed the upload but could not extract text or generate embeddings for the given file type. The error includes file.mimetype to help diagnose which file type was rejected.","triggerScenarios":"Calling uploadVectors({ req, file, file_id }) where file.mimetype is a type the RAG API cannot process — e.g., application/octet-stream, model/gltf-binary, or an uncommon format. The RAG API returns { status: true, known_type: false } indicating the upload was received but the type is unsupported.","commonSituations":"A user uploads a file type not supported by the RAG API's document parser (e.g., a .heic image, a .dwg CAD file, or a binary blob with a generic MIME type). Or the file's MIME type was detected incorrectly by multer (e.g., application/octet-stream for a PDF). Or the RAG API's supported types list is narrower than the upload form allows.","solutions":["Restrict accepted file types at the upload layer (multer fileFilter) to only MIME types the RAG API supports (typically PDF, TXT, DOCX, CSV, MD, etc.).","Verify file.mimetype is correctly detected — if multer reports application/octet-stream for a PDF, check the upload's Content-Type header.","Consult the RAG API documentation for the list of supported file types (known_type list).","Provide a clear user-facing error message listing accepted file types when this error occurs."],"exampleFix":"// before — no MIME type filtering\nconst upload = multer({ storage });\n\n// after — restrict to RAG-supported types\nconst ALLOWED_RAG_MIMETYPES = [\n  'application/pdf',\n  'text/plain',\n  'text/markdown',\n  'application/vnd.openxmlformats-officedocument.wordprocessingml.document',\n  'text/csv',\n];\nconst upload = multer({\n  storage,\n  fileFilter: (req, file, cb) => {\n    if (ALLOWED_RAG_MIMETYPES.includes(file.mimetype)) {\n      cb(null, true);\n    } else {\n      cb(new Error(`File type ${file.mimetype} is not supported for embedding`));\n    }\n  },\n});","handlingStrategy":"validation","validationCode":"const SUPPORTED_RAG_MIMETYPES = new Set([\n  'application/pdf', 'text/plain', 'text/markdown', 'text/csv',\n  'application/vnd.openxmlformats-officedocument.wordprocessingml.document',\n]);\nif (!SUPPORTED_RAG_MIMETYPES.has(file.mimetype)) {\n  throw new Error(`Unsupported file type for embedding: ${file.mimetype}`);\n}","typeGuard":"function isSupportedRagMimetype(mimetype: string): boolean {\n  const supported = new Set([\n    'application/pdf',\n    'text/plain',\n    'text/markdown',\n    'text/csv',\n    'application/vnd.openxmlformats-officedocument.wordprocessingml.document',\n    'application/json',\n  ]);\n  return supported.has(mimetype);\n}","tryCatchPattern":"try {\n  await uploadVectors({ req, file, file_id });\n} catch (error) {\n  if (error.message.includes('not supported')) {\n    return res.status(415).json({ error: `File type ${file.mimetype} is not supported for embedding` });\n  }\n  throw error;\n}","preventionTips":["Restrict accepted MIME types at the multer fileFilter layer to only RAG-supported types.","Verify file MIME type detection is correct — check the Content-Type header on upload.","Keep the allowed-types list in sync with the RAG API's supported file types.","Provide clear user-facing errors listing accepted file types."],"tags":["vectordb","rag","file-upload","input-validation","mime-type"],"backgroundTag":null,"analyzedSha":"5ff282f9006c436e561de1afd39a481bea1ef0d8","analyzedAt":"2026-08-12T21:38:08.145Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}