Budibase/budibase · error · HTTPError

SharePoint is not connected for this workspace

Error message

SharePoint is not connected for this workspace

What it means

Thrown by fetchSharePointEntriesForOperation when the matched SharePoint source's config is missing datasourceId or authConfigId. Without these credentials a bearer token cannot be obtained to call the SharePoint API.

Source

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

  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}`,
            name: drive.name,
            path: drive.name,
            type: "drive",
            driveId: drive.id,
            hasChildren: true,
          })
        ),
        ...lists.map(

View on GitHub (pinned to a81a902e9a)

Solutions

  1. Complete the SharePoint connection so datasourceId and authConfigId are saved on the source config
  2. Reconnect the site (remove and re-add it as a knowledge source) to regenerate the config
  3. Verify the datasource and auth config still exist in the workspace

Example fix

// before
const entries = await fetchSharePointEntriesForOperation({ agentId, operationId, siteId }) // 400 if unconnected
// after
const source = getSharePointSourcesForOperation(agent, operationId).find(s => s.config.site.id === siteId)
if (!source?.config.datasourceId || !source?.config.authConfigId) {
  throw new Error(`Site ${siteId} has no datasource/auth config; reconnect it in the workspace`)
}
const entries = await fetchSharePointEntriesForOperation({ agentId, operationId, siteId })
Defensive patterns

Strategy: validation

Validate before calling

const agent = await agentsSdk.getOrThrow(agentId)
const source = (agent.operations?.find(o => o.id === operationId)?.knowledgeSources || [])
  .find(s => s.config?.site?.id === siteId)
if (!source?.config.datasourceId || !source?.config.authConfigId) {
  throw new Error(`Site ${siteId} is missing datasource/auth configuration`)
}

Type guard

const isSharePointSourceConnected = (source: SharePointKnowledgeSource): boolean =>
  !!source.config.datasourceId && !!source.config.authConfigId

Try / catch

try {
  const entries = await fetchSharePointEntriesForOperation({ agentId, operationId, siteId })
} catch (err) {
  if (err instanceof HTTPError && err.status === 400) {
    // incomplete connection - direct user to reconnect the SharePoint site
  } else throw err
}

Prevention

When it happens

Trigger: Calling fetchSharePointEntriesForOperation where source.config.datasourceId or source.config.authConfigId is null/undefined — i.e. the site was added but its datasource/auth connection was never completed.

Common situations: Partially completed SharePoint connection flow, deleted datasource or auth config referenced by a stale source config, or workspace-level SharePoint setup skipped.

Related errors


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