danny-avila/LibreChat · error

File embedding failed. The filetype ${file.mimetype} is not

Error message

File embedding failed. The filetype ${file.mimetype} is not supported

What it means

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.

Source

Thrown at api/server/services/Files/VectorDB/crud.js:100

    if (storageMetadata) {
      formData.append('storage_metadata', JSON.stringify(storageMetadata));
    }

    const formHeaders = formData.getHeaders();

    const response = await axios.post(`${process.env.RAG_API_URL}/embed`, formData, {
      headers: {
        Authorization: `Bearer ${jwtToken}`,
        accept: 'application/json',
        ...formHeaders,
      },
    });

    const responseData = response.data;
    logger.debug('Response from embedding file', responseData);

    if (responseData.known_type === false) {
      throw new Error(`File embedding failed. The filetype ${file.mimetype} is not supported`);
    }

    if (!responseData.status) {
      throw new Error('File embedding failed.');
    }

    return {
      bytes: file.size,
      filename: file.originalname,
      filepath: FileSources.vectordb,
      embedded: Boolean(responseData.known_type),
    };
  } catch (error) {
    logAxiosError({
      error,
      message: 'Error uploading vectors',
    });
    throw new Error(error.message || 'An error occurred during file upload.');

View on GitHub (pinned to 5ff282f900)

Solutions

  1. 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.).
  2. Verify file.mimetype is correctly detected — if multer reports application/octet-stream for a PDF, check the upload's Content-Type header.
  3. Consult the RAG API documentation for the list of supported file types (known_type list).
  4. Provide a clear user-facing error message listing accepted file types when this error occurs.

Example fix

// before — no MIME type filtering
const upload = multer({ storage });

// after — restrict to RAG-supported types
const ALLOWED_RAG_MIMETYPES = [
  'application/pdf',
  'text/plain',
  'text/markdown',
  'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
  'text/csv',
];
const upload = multer({
  storage,
  fileFilter: (req, file, cb) => {
    if (ALLOWED_RAG_MIMETYPES.includes(file.mimetype)) {
      cb(null, true);
    } else {
      cb(new Error(`File type ${file.mimetype} is not supported for embedding`));
    }
  },
});
Defensive patterns

Strategy: validation

Validate before calling

const SUPPORTED_RAG_MIMETYPES = new Set([
  'application/pdf', 'text/plain', 'text/markdown', 'text/csv',
  'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
]);
if (!SUPPORTED_RAG_MIMETYPES.has(file.mimetype)) {
  throw new Error(`Unsupported file type for embedding: ${file.mimetype}`);
}

Type guard

function isSupportedRagMimetype(mimetype: string): boolean {
  const supported = new Set([
    'application/pdf',
    'text/plain',
    'text/markdown',
    'text/csv',
    'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
    'application/json',
  ]);
  return supported.has(mimetype);
}

Try / catch

try {
  await uploadVectors({ req, file, file_id });
} catch (error) {
  if (error.message.includes('not supported')) {
    return res.status(415).json({ error: `File type ${file.mimetype} is not supported for embedding` });
  }
  throw error;
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


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