Budibase/budibase · error · HTTPError

Specified SharePoint site is not connected for this operatio

Error message

Specified SharePoint site is not connected for this operation

What it means

Thrown by syncAgentKnowledgeSource with HTTP 400 when SharePoint sources exist for the operation but none matches the sourceId path parameter. The requested site is not among the operation's connected SharePoint sources.

Source

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

  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]
  )
  ctx.body = {
    agentId,
    sourceId,

View on GitHub (pinned to a81a902e9a)

Solutions

  1. Refresh the agent's source list and sync only IDs present in it.
  2. Remove cached sourceIds after a site is disconnected or the agent is edited.
  3. Verify the sourceId belongs to the same agentId/operationId being called.
  4. Handle this 400 by re-listing sources rather than retrying the same ID.

Example fix

// before
await api.syncKnowledgeSource(agentId, operationId, staleSourceId)
// after
const { sources } = await api.listKnowledgeSources(agentId, operationId)
const valid = sources.find(s => s.id === sourceId)
if (valid) await api.syncKnowledgeSource(agentId, operationId, valid.id)
Defensive patterns

Strategy: validation

Validate before calling

const agent = await api.getAgent(agentId)
const src = agent.operations?.find(op => op.id === operationId)?.knowledgeSources?.find(s => s.type === "sharepoint" && s.id === sourceId)
if (!src) throw new Error("source " + sourceId + " not connected")
await api.syncAgentKnowledgeSource(agentId, operationId, sourceId)

Type guard

function sourceIsConnected(agent, operationId, sourceId) {
  return Boolean(agent?.operations?.some(op => op.id === operationId && op.knowledgeSources?.some(s => s.id === sourceId)))
}

Try / catch

try {
  await api.syncAgentKnowledgeSource(agentId, operationId, sourceId)
} catch (err) {
  if (err.status === 400 && err.message.includes("Specified SharePoint site is not connected")) {
    // refresh the source list and drop the stale sourceId
  } else throw err
}

Prevention

When it happens

Trigger: Syncing with a sourceId from a deleted or disconnected SharePoint source; stale client state after the agent was edited; a typo/wrong ID (e.g. from a different agent or operation); case mismatch between stored and requested sourceId.

Common situations: Queued jobs or UI rows referencing sources removed by another admin; reusing sourceIds after reconnecting a site (new ID generated); hardcoded sourceIds in scripts.

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.

Related errors


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