Budibase/budibase · error · HTTPError

Unsupported file type for knowledge ingestion

Error message

Unsupported file type for knowledge ingestion

What it means

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.

Source

Thrown at packages/server/src/api/controllers/ai/files.ts:205

  )

  if (!upload) {
    throw new HTTPError("file is required", 400)
  }
  const filePath = upload.filepath || upload.path
  if (!filePath) {
    throw new HTTPError("Invalid upload payload", 400)
  }

  const filename = upload.originalFilename || upload.name || "agent-document"
  const mimetype = upload.mimetype || upload.type
  const fileSize =
    typeof upload.size === "number"
      ? upload.size
      : Number(upload.size) || undefined
  if (!isKnowledgeFileSupported({ filename, mimetype })) {
    await unlinkSafe(filePath)
    throw new HTTPError("Unsupported file type for knowledge ingestion", 400)
  }

  const buffer = await readFile(filePath)

  try {
    const updated = await sdk.ai.rag.uploadFileForOperation(
      agentId,
      operationId,
      {
        filename,
        mimetype,
        size: fileSize ?? buffer.byteLength,
        buffer,
        uploadedBy: ctx.user?._id!,
      }
    )
    ctx.body = { file: updated }
    ctx.status = 201

View on GitHub (pinned to a81a902e9a)

Solutions

  1. Convert the document to a supported format (PDF, DOCX, TXT, MD, etc. per isKnowledgeFileSupported).
  2. Check the allowlist in isKnowledgeFileSupported and confirm the file's extension and mimetype match a supported entry.
  3. Ensure the client sends the correct Content-Type for the file part.
  4. If the format should be supported, update the allowlist in isKnowledgeFileSupported.

Example fix

// before
form.append("file", zipBlob, "archive.zip")
// after
const pdfBlob = await convertToPdf(zipBlob)
form.append("file", pdfBlob, "archive.pdf")
Defensive patterns

Strategy: validation

Validate before calling

const SUPPORTED_EXT = [/\.pdf$/i, /\.docx?$/i, /\.txt$/i, /\.md$/i]
const ok = SUPPORTED_EXT.some(re => re.test(filename)) || SUPPORTED_MIMES.includes(mimetype)
if (!ok) throw new Error("Unsupported file type: " + filename)

Try / catch

try {
  await api.uploadAgentFile(agentId, operationId, form)
} catch (err) {
  if (err.message === "Unsupported file type for knowledge ingestion") {
    // convert the file or notify the user of allowed formats
  } else throw err
}

Prevention

When it happens

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

Common situations: Users attaching arbitrary documents to a chat agent; CI scripts uploading generated artifacts (logs, zips); client OS/browser sending mimetypes not on the allowlist.

Related errors


AI-assisted analysis of Budibase/budibase@a81a902e9a (2026-08-29). Data as JSON: /api/errors/505e1b827c3526d3. Report an issue: GitHub.