{"record":{"id":"437efbf806528546","repo":"Budibase/budibase","slug":"sharepoint-is-not-connected-for-this-operation","errorCode":null,"errorMessage":"SharePoint is not connected for this operation","messagePattern":"SharePoint is not connected for this operation","errorType":"http","errorClass":"HTTPError","httpStatus":400,"severity":"error","filePath":"packages/server/src/api/controllers/ai/files.ts","lineNumber":361,"sourceCode":"    agentId,\n    operationId\n  )\n  await sdk.ai.knowledgeBase.resetKnowledgeBaseStore(knowledgeBase)\n  ctx.status = 204\n}\n\nexport async function syncAgentKnowledgeSource(\n  ctx: UserCtx<\n    SyncAgentKnowledgeSourcesRequest,\n    SyncAgentKnowledgeSourcesResponse,\n    { agentId: string; operationId: string; sourceId: string }\n  >\n) {\n  const { agentId, operationId, sourceId } = ctx.params\n  const agent = await sdk.ai.agents.getOrThrow(agentId)\n  const sharePointSources = getSharePointSourcesForOperation(agent, operationId)\n  if (sharePointSources.length === 0) {\n    throw new HTTPError(\"SharePoint is not connected for this operation\", 400)\n  }\n  const source = sharePointSources.find(source => source.id === sourceId)\n  if (!source) {\n    throw new HTTPError(\n      \"Specified SharePoint site is not connected for this operation\",\n      400\n    )\n  }\n\n  console.log(\"Agent knowledge source sync requested\", {\n    agentId,\n    operationId,\n    sourceId,\n  })\n  await sdk.ai.rag.knowledgeSourceSyncQueue.enqueueAgentJobs(\n    agentId,\n    AgentKnowledgeSourceType.SHAREPOINT,\n    [sourceId]","sourceCodeStart":343,"sourceCodeEnd":379,"githubUrl":"https://github.com/Budibase/budibase/blob/a81a902e9a8fe55b467d106765f6638f12e35c49/packages/server/src/api/controllers/ai/files.ts#L343-L379","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Connect at least one SharePoint site to the operation before triggering syncs.","Re-fetch the agent config before sync to avoid stale knowledge-source lists.","Hide sync controls in the UI when no SharePoint sources exist.","Verify the operationId is correct for the agent being synced."],"exampleFix":"// before\nawait api.syncKnowledgeSource(agentId, operationId, sourceId)\n// after\nconst agent = await api.getAgent(agentId)\nconst hasSp = agent.operations.find(op => op.id === operationId)?.knowledgeSources?.some(s => s.type === \"sharepoint\")\nif (!hasSp) return // prompt user to connect SharePoint first\nawait api.syncKnowledgeSource(agentId, operationId, sourceId)","handlingStrategy":"validation","validationCode":"const agent = await api.getAgent(agentId)\nconst hasSharePoint = agent.operations?.find(op => op.id === operationId)?.knowledgeSources?.some(s => s.type === \"sharepoint\")\nif (!hasSharePoint) throw new Error(\"connect SharePoint first\")","typeGuard":"function hasSharePointSources(agent, operationId) {\n  return Boolean(agent?.operations?.some(op => op.id === operationId && op.knowledgeSources?.some(s => s.type === \"sharepoint\")))\n}","tryCatchPattern":"try {\n  await api.syncAgentKnowledgeSource(agentId, operationId, sourceId)\n} catch (err) {\n  if (err.status === 400 && err.message === \"SharePoint is not connected for this operation\") {\n    // prompt the user to connect a SharePoint site first\n  } else throw err\n}","preventionTips":["Connect at least one SharePoint site to the operation before triggering syncs.","Re-fetch agent config before sync to avoid stale knowledge-source lists.","Hide sync controls when no SharePoint sources exist.","Handle operation deletions/edits that remove configured sources."],"tags":["http-400","configuration","sharepoint","knowledge-base"],"backgroundTag":"resource-not-configured","analyzedSha":"a81a902e9a8fe55b467d106765f6638f12e35c49","analyzedAt":"2026-08-29T01:03:10.972Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}