Budibase/budibase · error · HTTPError

Failed to create operation file storage

Error message

Failed to create operation file storage

What it means

uploadFileForOperation ensures a knowledge base exists for the agent operation, then uploads the file into it. If the ensured knowledge base comes back without an _id, the SDK cannot target storage, so it throws HTTPError 500 "Failed to create operation file storage" — an internal invariant failure meaning storage provisioning silently failed.

Source

Thrown at packages/server/src/sdk/workspace/ai/rag/files.ts:210

  return (
    await Promise.all(
      knowledgeBaseIds.map(id => knowledgeBaseSdk.listKnowledgeBaseFiles(id))
    )
  ).flat()
}

export const uploadFileForOperation = async (
  agentId: string,
  operationId: string,
  input: UploadKnowledgeFileInput
): Promise<KnowledgeBaseFile> => {
  const knowledgeBase = await ensureKnowledgeBaseForOperation(
    agentId,
    operationId
  )
  const knowledgeBaseId = knowledgeBase._id
  if (!knowledgeBaseId) {
    throw new HTTPError("Failed to create operation file storage", 500)
  }

  return await knowledgeBaseSdk.uploadKnowledgeBaseFile({
    knowledgeBaseId,
    filename: input.filename,
    mimetype: input.mimetype,
    size: input.size ?? input.buffer.byteLength,
    buffer: input.buffer,
    uploadedBy: input.uploadedBy,
  })
}

export const deleteFileForOperation = async (
  agentId: string,
  operationId: string,
  fileId: string
): Promise<void> => {
  const file = await knowledgeBaseSdk.getKnowledgeBaseFileOrThrow(fileId)

View on GitHub (pinned to a81a902e9a)

Solutions

  1. Check server logs and CouchDB health for failures during knowledge base creation.
  2. Verify the knowledge base backend/provider configuration is correct and the service is reachable.
  3. Retry the upload — creation may have been a transient failure.
  4. If reproducible, inspect ensureKnowledgeBaseForOperation for a path that returns a document without persisting it.

Example fix

// before
await uploadFileForOperation(agentId, operationId, input)
// after
try {
  await uploadFileForOperation(agentId, operationId, input)
} catch (e) {
  if (e instanceof HTTPError && e.status === 500) {
    // log and retry or report knowledge base provisioning failure
  }
  throw e
}
Defensive patterns

Strategy: try-catch

Validate before calling

null

Type guard

null

Try / catch

try {
  await uploadFileForOperation(agentId, operationId, input)
} catch (e) {
  if (e instanceof HTTPError && e.status === 500 && e.message === "Failed to create operation file storage") {
    // log provisioning failure, retry once, else surface infra error
  }
  throw e
}

Prevention

When it happens

Trigger: Calling uploadFileForOperation when ensureKnowledgeBaseForOperation returns a knowledge base document lacking _id — e.g. the underlying knowledge-base creation call failed or returned an unexpected/empty document.

Common situations: Database (CouchDB) write issues during knowledge base creation; provider/backend misconfiguration causing the knowledge base SDK to return a stub; concurrent creation races returning incomplete documents.

Related errors


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