Budibase/budibase · error · HTTPError

SharePoint is not connected for this operation

Error message

SharePoint is not connected for this operation

What it means

Thrown by syncAgentKnowledgeSource with HTTP 400 when the agent's operation has no SharePoint knowledge sources configured at all, so there is nothing to sync. The check runs against the agent document via getSharePointSourcesForOperation.

Source

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

    agentId,
    operationId
  )
  await sdk.ai.knowledgeBase.resetKnowledgeBaseStore(knowledgeBase)
  ctx.status = 204
}

export async function syncAgentKnowledgeSource(
  ctx: UserCtx<
    SyncAgentKnowledgeSourcesRequest,
    SyncAgentKnowledgeSourcesResponse,
    { agentId: string; operationId: string; sourceId: string }
  >
) {
  const { agentId, operationId, sourceId } = ctx.params
  const agent = await sdk.ai.agents.getOrThrow(agentId)
  const sharePointSources = getSharePointSourcesForOperation(agent, operationId)
  if (sharePointSources.length === 0) {
    throw new HTTPError("SharePoint is not connected for this operation", 400)
  }
  const source = sharePointSources.find(source => source.id === sourceId)
  if (!source) {
    throw new HTTPError(
      "Specified SharePoint site is not connected for this operation",
      400
    )
  }

  console.log("Agent knowledge source sync requested", {
    agentId,
    operationId,
    sourceId,
  })
  await sdk.ai.rag.knowledgeSourceSyncQueue.enqueueAgentJobs(
    agentId,
    AgentKnowledgeSourceType.SHAREPOINT,
    [sourceId]

View on GitHub (pinned to a81a902e9a)

Solutions

  1. Connect at least one SharePoint site to the operation before triggering syncs.
  2. Re-fetch the agent config before sync to avoid stale knowledge-source lists.
  3. Hide sync controls in the UI when no SharePoint sources exist.
  4. Verify the operationId is correct for the agent being synced.

Example fix

// before
await api.syncKnowledgeSource(agentId, operationId, sourceId)
// after
const agent = await api.getAgent(agentId)
const hasSp = agent.operations.find(op => op.id === operationId)?.knowledgeSources?.some(s => s.type === "sharepoint")
if (!hasSp) return // prompt user to connect SharePoint first
await api.syncKnowledgeSource(agentId, operationId, sourceId)
Defensive patterns

Strategy: validation

Validate before calling

const agent = await api.getAgent(agentId)
const hasSharePoint = agent.operations?.find(op => op.id === operationId)?.knowledgeSources?.some(s => s.type === "sharepoint")
if (!hasSharePoint) throw new Error("connect SharePoint first")

Type guard

function hasSharePointSources(agent, operationId) {
  return Boolean(agent?.operations?.some(op => op.id === operationId && op.knowledgeSources?.some(s => s.type === "sharepoint")))
}

Try / catch

try {
  await api.syncAgentKnowledgeSource(agentId, operationId, sourceId)
} catch (err) {
  if (err.status === 400 && err.message === "SharePoint is not connected for this operation") {
    // prompt the user to connect a SharePoint site first
  } else throw err
}

Prevention

When it happens

Trigger: Triggering a sync for an operation before any SharePoint site has been connected; the operation's SharePoint sources were removed/disconnected while the client still attempted syncs; wrong operationId pointing to an operation without SharePoint sources.

Common situations: Scheduling automations that sync knowledge sources before setup completed; clients caching old agent config showing sources that were since disconnected; copying a sync call across agents.

Related errors


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