Budibase/budibase · error · HTTPError

SharePoint is not connected for this operation

Error message

SharePoint is not connected for this operation

What it means

syncSharePointSourcesForOperation looks up the agent's SharePoint knowledge sources attached to the given operationId via getSharePointSourcesForOperation and throws this 400 HTTPError when the operation has no SharePoint sources configured. It is an early guard so sync is not attempted for operations without a SharePoint integration.

Source

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

      _deleted: true,
    }))

  if (docsToDelete.length > 0) {
    await db.bulkDocs(docsToDelete)
  }
}

const runSharePointSourcesForOperation = async (
  agentId: string,
  operationId: string,
  sourceId: string,
  signal?: AbortSignal
): Promise<SharePointSyncResult> => {
  const lastRunAt = new Date().toISOString()
  const agent = await agentsSdk.getOrThrow(agentId)
  const sharepointSources = getSharePointSourcesForOperation(agent, operationId)
  if (sharepointSources.length === 0) {
    throw new HTTPError("SharePoint is not connected for this operation", 400)
  }

  const knowledgeSource = getSharePointSourcesForOperation(
    agent,
    operationId
  ).find(source => source.id === sourceId)
  const site = knowledgeSource?.config.site
  const sourceDatasourceId = knowledgeSource?.config.datasourceId
  const sourceAuthConfigId = knowledgeSource?.config.authConfigId
  if (!site) {
    throw new HTTPError(
      "Specified SharePoint site is not connected for this operation",
      400
    )
  }

  const siteId = site.id
  const sourceScope = knowledgeSource?.config.scope

View on GitHub (pinned to a81a902e9a)

Solutions

  1. Add a SharePoint knowledge source to the agent operation before triggering sync
  2. Confirm the operationId belongs to the agent you are syncing (agentsSdk.getOrThrow + inspect its knowledge sources)
  3. Re-check the agent document for concurrent edits that removed the source
  4. Use the agent-level sync entry point which resolves the operationId from sourceId instead
Defensive patterns

Strategy: validation

Validate before calling

const agent = await agentsSdk.getOrThrow(agentId)
const sources = getSharePointSourcesForOperation(agent, operationId)
if (sources.length === 0) {
  throw new Error(`Operation ${operationId} has no SharePoint sources`)
}

Type guard

const hasSharePointSources = (agent: Agent, operationId: string): boolean =>
  getSharePointSourcesForOperation(agent, operationId).length > 0

Try / catch

try {
  await syncSharePointSourcesForOperation(agentId, operationId, sourceId)
} catch (err) {
  if (err instanceof HTTPError && err.status === 400 && err.message === "SharePoint is not connected for this operation") {
    // prompt user to connect a SharePoint source before syncing
  } else { throw err }
}

Prevention

When it happens

Trigger: Calling the sync API (e.g. syncSharePointSourcesForOperation or a route that reaches it) with an operationId that has no SharePoint knowledge source entries on the agent document.

Common situations: Sync triggered before the SharePoint source was saved on the agent; operationId typo or an operation from a different agent; the SharePoint source was deleted by another user before sync ran.

Related errors


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