danny-avila/LibreChat · warning
Image uploads are not supported for file search tool resourc
Error message
Image uploads are not supported for file search tool resources
What it means
Thrown when `tool_resource === EToolResources.file_search` AND the uploaded file's mimetype starts with `image/`. The file_search tool indexes text for retrieval; images are not parsable for the vector store and would be silently ignored, so the server rejects them early. This guard runs before capability checks.
Source
Thrown at api/server/services/Files/process.js:682
* @param {ServerRequest} params.req - The Express request object.
* @param {Express.Response} params.res - The Express response object.
* @param {FileMetadata} params.metadata - Additional metadata for the file.
* @param {import('@librechat/api').UploadSseStream | null} [params.sseStream] - Active upload SSE stream, if enabled.
* @returns {Promise<void>}
*/
const processAgentFileUpload = async ({ req, res, metadata, sseStream }) => {
const { file } = req;
const appConfig = req.config;
const { agent_id, tool_resource, file_id, temp_file_id = null } = metadata;
let messageAttachment = !!metadata.message_file;
if (agent_id && !tool_resource && !messageAttachment) {
throw new Error('No tool resource provided for agent file upload');
}
if (tool_resource === EToolResources.file_search && file.mimetype.startsWith('image')) {
throw new Error('Image uploads are not supported for file search tool resources');
}
if (!messageAttachment && !agent_id) {
throw new Error('No agent ID provided for agent file upload');
}
const isImage = file.mimetype.startsWith('image');
let fileInfoMetadata;
const entity_id = messageAttachment === true ? undefined : agent_id;
const basePath = mime.getType(file.originalname)?.startsWith('image') ? 'images' : 'uploads';
if (tool_resource === EToolResources.execute_code) {
const isCodeEnabled = await checkCapability(req, AgentCapabilities.execute_code);
if (!isCodeEnabled) {
throw new Error('Code execution is not enabled for Agents');
}
const { handleFileUpload: uploadCodeEnvFile } = getStrategyFunctions(FileSources.execute_code);
const stream = fs.createReadStream(file.path);
/* Resource identity for codeapi's sessionKey:View on GitHub (pinned to 5ff282f900)
Solutions
- Upload text-based documents (PDF, DOCX, TXT, MD) for file_search — not images.
- Filter the file picker `accept` attribute by tool resource on the frontend.
- If the user wants to attach an image, switch the tool_resource to one that supports images or send as a message_file.
- Verify the file's actual MIME: a `.pdf` renamed to `.png` would still be detected as image by Multer's extension sniff.
Example fix
// before
<input type="file" />
// after
<input type="file" accept={toolResource === 'file_search' ? '.pdf,.docx,.txt,.md' : '*/*'} /> Defensive patterns
Strategy: validation
Validate before calling
function assertFileSearchMime(file, tool_resource) {
if (tool_resource === 'file_search' && file.mimetype.startsWith('image/')) {
throw new Error('file_search does not accept images');
}
} Try / catch
try { await processAgentFileUpload(params); }
catch (e) {
if (/Image uploads are not supported for file search/.test(e.message)) return res.status(415).json({ error: e.message });
throw e;
} Prevention
- Bind the file input's `accept` attribute to the active tool_resource.
- Filter out images in the upload handler for file_search agents.
- If the user wants to share an image, route it as a message_file or another tool_resource.
When it happens
Trigger: User attaches a PNG/JPG to an agent whose active tool_resource is `file_search`. The MIME is detected from `file.mimetype` (set by Multer from the uploaded filename/Content-Type) and matched against the literal prefix `image`.
Common situations: UI lets users drop any file type onto a file_search agent; a multi-file upload mixing PDFs and screenshots; frontend not filtering file types per tool resource; MIME sniffed wrong because the file has an image extension.
Related errors
- No tool resource provided for agent file upload
- No agent ID provided for agent file upload
- File search is not enabled for Agents
- File type ${file.mimetype} is not supported for text parsing
- [${req.baseUrl}] Endpoint is required
AI-assisted analysis of danny-avila/LibreChat@5ff282f900 (2026-08-12).
Data as JSON: /api/errors/0cee367ccbc398a6.
Report an issue: GitHub.