Budibase/budibase · error · HTTPError

Failed to create agent file storage

Error message

Failed to create agent file storage

What it means

Before syncing files, the code calls ensureKnowledgeBaseForOperation to create/obtain the knowledge base backing the operation's file storage. If the returned document has no _id, this 500 HTTPError is thrown — creation nominally succeeded but produced no usable identifier, so sync cannot proceed.

Source

Thrown at packages/server/src/sdk/workspace/ai/rag/sources/sharepoint/sharepoint.ts:772

    runAt: lastRunAt,
    sourceScope,
  })
  throwIfSyncAborted(signal)

  if (!sourceDatasourceId || !sourceAuthConfigId) {
    throw new HTTPError("SharePoint is not connected for this workspace", 400)
  }
  const bearerToken = await getSharePointBearerToken(
    sourceDatasourceId,
    sourceAuthConfigId
  )
  const knowledgeBase = await ensureKnowledgeBaseForOperation(
    agentId,
    operationId
  )
  const knowledgeBaseId = knowledgeBase._id
  if (!knowledgeBaseId) {
    throw new HTTPError("Failed to create agent file storage", 500)
  }

  const existingFiles =
    await knowledgeBaseSdk.listKnowledgeBaseFiles(knowledgeBaseId)
  const existingSharePointFilesByExternalId = new Map<
    string,
    {
      fileId: string
      siteId: string
      knowledgeSourceId?: string
      status?: KnowledgeBaseFileStatus
      etag?: string
      lastModifiedAt?: string
      remoteSize?: number
    }
  >()
  for (const file of existingFiles) {
    const fileId = file._id

View on GitHub (pinned to a81a902e9a)

Solutions

  1. Retry the sync (may be a transient DB race); if recurring, investigate ensureKnowledgeBaseForOperation
  2. Check server logs and CouchDB for errors around knowledge base creation at that timestamp
  3. Verify the knowledge-base SDK version in use matches the server code
  4. Re-run sync with a single worker to avoid concurrent creation races
Defensive patterns

Strategy: retry

Validate before calling

const kb = await ensureKnowledgeBaseForOperation(agentId, operationId)
if (!kb?._id) {
  throw new Error("Knowledge base creation returned no id")
}

Type guard

const hasKnowledgeBaseId = (
  kb: KnowledgeBase | undefined
): kb is KnowledgeBase & { _id: string } =>
  typeof kb?._id === "string" && kb._id.length > 0

Try / catch

try {
  await syncSharePointSourceForAgent(agentId, sourceId)
} catch (err) {
  if (err instanceof HTTPError && err.status === 500 && err.message.includes("agent file storage")) {
    // retry once after short backoff, then alert/inspect logs
  } else { throw err }
}

Prevention

When it happens

Trigger: ensureKnowledgeBaseForOperation returns a document without _id — e.g. a DB write/creation path returning an unexpected shape, or a race where the KB record exists but is not persisted with an id.

Common situations: CouchDB/DB issues during KB creation; concurrent syncs racing to create the same knowledge base; a bug or version mismatch in the knowledge-base SDK; corrupted agent operation records.

Related errors


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