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._idView on GitHub (pinned to a81a902e9a)
Solutions
- Retry the sync (may be a transient DB race); if recurring, investigate ensureKnowledgeBaseForOperation
- Check server logs and CouchDB for errors around knowledge base creation at that timestamp
- Verify the knowledge-base SDK version in use matches the server code
- 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
- Serialize syncs per agent/operation to avoid concurrent KB creation races
- Monitor DB health where knowledge bases are stored
- Verify KB SDK versions match server code
- Alert on ensureKnowledgeBaseForOperation returning docs without _id
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
- Unsupported file type for knowledge ingestion
- ${error?.message} || Failed to process uploaded file
- Knowledge source downloads are disabled for this operation
- SharePoint is not connected for this operation
- Knowledge base id not set
AI-assisted analysis of Budibase/budibase@a81a902e9a (2026-08-29).
Data as JSON: /api/errors/f13cfd53ac6317ee.
Report an issue: GitHub.