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 updateAgentSharePointSite when no existing SharePoint source on the agent for the given operationId matches the supplied siteId. The controller looks up the agent, filters its SharePoint sources by operation, then finds the one whose config.site.id equals the request's siteId; a 404 is raised if none match.

Source

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

  )
  ctx.status = 200
}

export async function updateAgentSharePointSite(
  ctx: UserCtx<
    UpdateAgentSharePointSiteRequest,
    UpdateAgentSharePointSiteResponse,
    { agentId: string; operationId: string; siteId: string }
  >
) {
  const { agentId, operationId, siteId } = ctx.params
  const existingAgent = await sdk.ai.agents.getOrThrow(agentId)
  const source = getSharePointSourcesForOperation(
    existingAgent,
    operationId
  ).find(source => source.config.site.id === siteId)
  if (!source) {
    throw new HTTPError(
      "SharePoint site is not connected for this operation",
      404
    )
  }

  const { scope } = ctx.request.body
  const updated = await sdk.ai.agents.update({
    ...existingAgent,
    operations: updateOperationKnowledgeSources(
      existingAgent,
      operationId,
      sources => {
        const nonSharePointSources = sources.filter(
          source => source.type !== AgentKnowledgeSourceType.SHAREPOINT
        )
        const sharePointSources = sources
          .filter(source => source.type === AgentKnowledgeSourceType.SHAREPOINT)
          .map(existingSource =>

View on GitHub (pinned to a81a902e9a)

Solutions

  1. List the agent's connected SharePoint sources for the operation first and use one of the returned site ids.
  2. Verify the operationId in the path matches the operation the site was originally connected to.
  3. Re-connect the site via the connect endpoint before attempting to update it.

Example fix

// before
await api.put(`/ai/agents/${agentId}/operations/${opId}/sharepoint/${staleSiteId}`, { scope: 'items' })
// after
const sources = await getAgentSharePointSources(agentId, opId)
await api.put(`/ai/agents/${agentId}/operations/${opId}/sharepoint/${sources[0].config.site.id}`, { scope: 'items' })
Defensive patterns

Strategy: validation

Validate before calling

const sources = await getAgentSharePointSources(agentId, operationId)
const site = sources.find(s => s.config.site.id === siteId)
if (!site) throw new Error(`Site ${siteId} is not connected to operation ${operationId}`)

Type guard

function findConnectedSource(sources: SharePointSource[], siteId: string): SharePointSource | undefined {
  return sources.find(s => typeof s.config?.site?.id === 'string' && s.config.site.id === siteId)
}

Try / catch

try {
  await updateAgentSharePointSite({ agentId, operationId, siteId, scope })
} catch (e) {
  if (e instanceof HTTPError && e.status === 404) {
    // refresh agent config / re-connect site before updating
  } else throw e
}

Prevention

When it happens

Trigger: Calling the agent SharePoint site update endpoint with an operationId that has no connected SharePoint sources, a siteId that was never connected, or a siteId connected under a different operation.

Common situations: Site was disconnected earlier; client caches a stale siteId after an agent config change; wrong operationId in the URL path; agent was recreated so old source references no longer exist.

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/491585c773173535. Report an issue: GitHub.