Budibase/budibase · error · HTTPError

SharePoint site is not connected for this operation

Error message

SharePoint site is not connected for this operation

What it means

Thrown by fetchSharePointEntriesForOperation when no SharePoint source on the specified operation matches the given siteId. The site is treated as not connected, so its entries cannot be fetched.

Source

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

  }

  return false
}

export const fetchSharePointEntriesForOperation = async (
  agentId: string,
  operationId: string,
  siteId: string,
  driveId?: string,
  parentItemId?: string,
  parentPath = ""
): Promise<FetchAgentKnowledgeSourceEntriesResponse> => {
  const agent = await agentsSdk.getOrThrow(agentId)
  const source = getSharePointSourcesForOperation(agent, operationId).find(
    source => source.config.site.id === siteId
  )
  if (!source) {
    throw new HTTPError(
      "SharePoint site is not connected for this operation",
      404
    )
  }

  const { datasourceId, authConfigId } = source.config
  if (!datasourceId || !authConfigId) {
    throw new HTTPError("SharePoint is not connected for this workspace", 400)
  }
  const bearerToken = await getSharePointBearerToken(datasourceId, authConfigId)
  const drives = await listSharePointDrives(bearerToken, siteId)
  if (!driveId) {
    const lists = await listSharePointLists(bearerToken, siteId)
    return {
      entries: [
        ...drives.map(
          (drive): KnowledgeSourceEntry => ({
            id: `drive:${drive.id}`,

View on GitHub (pinned to a81a902e9a)

Solutions

  1. Re-fetch the connected SharePoint sites for the operation and use a valid siteId
  2. Reconnect the SharePoint site to the operation before fetching entries
  3. Confirm the operationId and siteId pair match the agent's current knowledge source config

Example fix

// before
await fetchSharePointEntriesForOperation({ agentId, operationId, siteId: removedSiteId }) // 404
// after
const agent = await agentsSdk.getOrThrow(agentId)
const sites = (agent.operations?.find(op => op.id === operationId)?.knowledgeSources || [])
  .filter(s => s.type === 'sharepoint')
if (!sites.some(s => s.config.site.id === siteId)) {
  throw new Error(`Site ${siteId} is not connected; reconnect it first`)
}
await fetchSharePointEntriesForOperation({ agentId, operationId, siteId })
Defensive patterns

Strategy: validation

Validate before calling

const agent = await agentsSdk.getOrThrow(agentId)
const connected = (agent.operations?.find(o => o.id === operationId)?.knowledgeSources || [])
  .some(s => s.config?.site?.id === siteId)
if (!connected) throw new Error(`Site ${siteId} is not connected to operation ${operationId}`)

Type guard

const isSiteConnected = (agent: Agent, operationId: string, siteId: string): boolean =>
  (agent.operations?.find(o => o.id === operationId)?.knowledgeSources || [])
    .some(s => s.config?.site?.id === siteId)

Try / catch

try {
  const entries = await fetchSharePointEntriesForOperation({ agentId, operationId, siteId })
} catch (err) {
  if (err instanceof HTTPError && err.status === 404) {
    // site disconnected - offer the user a reconnect flow
  } else throw err
}

Prevention

When it happens

Trigger: Calling fetchSharePointEntriesForOperation with a siteId that is not in the operation's knowledgeSources SharePoint configs, or using an operation that has no SharePoint sources at all.

Common situations: Site disconnected through the UI while a client still holds its id, wrong siteId casing/format, or querying against the wrong operation.

Related errors


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