{"record":{"id":"505e1b827c3526d3","repo":"Budibase/budibase","slug":"unsupported-file-type-for-knowledge-ingestion","errorCode":null,"errorMessage":"Unsupported file type for knowledge ingestion","messagePattern":"Unsupported file type for knowledge ingestion","errorType":"http","errorClass":"HTTPError","httpStatus":400,"severity":"error","filePath":"packages/server/src/api/controllers/ai/files.ts","lineNumber":205,"sourceCode":"  )\n\n  if (!upload) {\n    throw new HTTPError(\"file is required\", 400)\n  }\n  const filePath = upload.filepath || upload.path\n  if (!filePath) {\n    throw new HTTPError(\"Invalid upload payload\", 400)\n  }\n\n  const filename = upload.originalFilename || upload.name || \"agent-document\"\n  const mimetype = upload.mimetype || upload.type\n  const fileSize =\n    typeof upload.size === \"number\"\n      ? upload.size\n      : Number(upload.size) || undefined\n  if (!isKnowledgeFileSupported({ filename, mimetype })) {\n    await unlinkSafe(filePath)\n    throw new HTTPError(\"Unsupported file type for knowledge ingestion\", 400)\n  }\n\n  const buffer = await readFile(filePath)\n\n  try {\n    const updated = await sdk.ai.rag.uploadFileForOperation(\n      agentId,\n      operationId,\n      {\n        filename,\n        mimetype,\n        size: fileSize ?? buffer.byteLength,\n        buffer,\n        uploadedBy: ctx.user?._id!,\n      }\n    )\n    ctx.body = { file: updated }\n    ctx.status = 201","sourceCodeStart":187,"sourceCodeEnd":223,"githubUrl":"https://github.com/Budibase/budibase/blob/a81a902e9a8fe55b467d106765f6638f12e35c49/packages/server/src/api/controllers/ai/files.ts#L187-L223","documentation":"Thrown when isKnowledgeFileSupported rejects the uploaded file's filename extension/mimetype, meaning the knowledge ingestion pipeline (Gemini file search) cannot process that format. The temp file is deleted and HTTP 400 is returned.","triggerScenarios":"Uploading an unsupported extension (e.g. .exe, .zip, unsupported images) to the agent knowledge upload endpoint; a file whose mimetype is missing or wrong so the allowlist check fails; files generated by scripts with formats outside the allowlist.","commonSituations":"Users attaching arbitrary documents to a chat agent; CI scripts uploading generated artifacts (logs, zips); client OS/browser sending mimetypes not on the allowlist.","solutions":["Convert the document to a supported format (PDF, DOCX, TXT, MD, etc. per isKnowledgeFileSupported).","Check the allowlist in isKnowledgeFileSupported and confirm the file's extension and mimetype match a supported entry.","Ensure the client sends the correct Content-Type for the file part.","If the format should be supported, update the allowlist in isKnowledgeFileSupported."],"exampleFix":"// before\nform.append(\"file\", zipBlob, \"archive.zip\")\n// after\nconst pdfBlob = await convertToPdf(zipBlob)\nform.append(\"file\", pdfBlob, \"archive.pdf\")","handlingStrategy":"validation","validationCode":"const SUPPORTED_EXT = [/\\.pdf$/i, /\\.docx?$/i, /\\.txt$/i, /\\.md$/i]\nconst ok = SUPPORTED_EXT.some(re => re.test(filename)) || SUPPORTED_MIMES.includes(mimetype)\nif (!ok) throw new Error(\"Unsupported file type: \" + filename)","typeGuard":null,"tryCatchPattern":"try {\n  await api.uploadAgentFile(agentId, operationId, form)\n} catch (err) {\n  if (err.message === \"Unsupported file type for knowledge ingestion\") {\n    // convert the file or notify the user of allowed formats\n  } else throw err\n}","preventionTips":["Filter files client-side against the supported extension/mimetype list before upload.","Always send an accurate Content-Type for file parts.","Convert exotic formats (zip, exe, images) to PDF/TXT before ingestion.","Keep the server allowlist in sync with what the ingestion API accepts."],"tags":["http-400","validation","file-type","knowledge-base"],"backgroundTag":"unsupported-file-type","analyzedSha":"a81a902e9a8fe55b467d106765f6638f12e35c49","analyzedAt":"2026-08-29T01:03:10.972Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}