{"record":{"id":"0cee367ccbc398a6","repo":"danny-avila/LibreChat","slug":"image-uploads-are-not-supported-for-file-search-to","errorCode":null,"errorMessage":"Image uploads are not supported for file search tool resources","messagePattern":"Image uploads are not supported for file search tool resources","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"api/server/services/Files/process.js","lineNumber":682,"sourceCode":" * @param {ServerRequest} params.req - The Express request object.\n * @param {Express.Response} params.res - The Express response object.\n * @param {FileMetadata} params.metadata - Additional metadata for the file.\n * @param {import('@librechat/api').UploadSseStream | null} [params.sseStream] - Active upload SSE stream, if enabled.\n * @returns {Promise<void>}\n */\nconst processAgentFileUpload = async ({ req, res, metadata, sseStream }) => {\n  const { file } = req;\n  const appConfig = req.config;\n  const { agent_id, tool_resource, file_id, temp_file_id = null } = metadata;\n\n  let messageAttachment = !!metadata.message_file;\n\n  if (agent_id && !tool_resource && !messageAttachment) {\n    throw new Error('No tool resource provided for agent file upload');\n  }\n\n  if (tool_resource === EToolResources.file_search && file.mimetype.startsWith('image')) {\n    throw new Error('Image uploads are not supported for file search tool resources');\n  }\n\n  if (!messageAttachment && !agent_id) {\n    throw new Error('No agent ID provided for agent file upload');\n  }\n\n  const isImage = file.mimetype.startsWith('image');\n  let fileInfoMetadata;\n  const entity_id = messageAttachment === true ? undefined : agent_id;\n  const basePath = mime.getType(file.originalname)?.startsWith('image') ? 'images' : 'uploads';\n  if (tool_resource === EToolResources.execute_code) {\n    const isCodeEnabled = await checkCapability(req, AgentCapabilities.execute_code);\n    if (!isCodeEnabled) {\n      throw new Error('Code execution is not enabled for Agents');\n    }\n    const { handleFileUpload: uploadCodeEnvFile } = getStrategyFunctions(FileSources.execute_code);\n    const stream = fs.createReadStream(file.path);\n    /* Resource identity for codeapi's sessionKey:","sourceCodeStart":664,"sourceCodeEnd":700,"githubUrl":"https://github.com/danny-avila/LibreChat/blob/5ff282f9006c436e561de1afd39a481bea1ef0d8/api/server/services/Files/process.js#L664-L700","documentation":"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.","triggerScenarios":"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`.","commonSituations":"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.","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."],"exampleFix":"// before\n<input type=\"file\" />\n\n// after\n<input type=\"file\" accept={toolResource === 'file_search' ? '.pdf,.docx,.txt,.md' : '*/*'} />","handlingStrategy":"validation","validationCode":"function assertFileSearchMime(file, tool_resource) {\n  if (tool_resource === 'file_search' && file.mimetype.startsWith('image/')) {\n    throw new Error('file_search does not accept images');\n  }\n}","typeGuard":null,"tryCatchPattern":"try { await processAgentFileUpload(params); }\ncatch (e) {\n  if (/Image uploads are not supported for file search/.test(e.message)) return res.status(415).json({ error: e.message });\n  throw e;\n}","preventionTips":["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."],"tags":["agent","file-search","mime-type","validation"],"backgroundTag":null,"analyzedSha":"5ff282f9006c436e561de1afd39a481bea1ef0d8","analyzedAt":"2026-08-12T21:38:08.145Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}