{"record":{"id":"361eeef70776a933","repo":"Budibase/budibase","slug":"sharepoint-is-not-connected-for-this-operation-361eee","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/sdk/workspace/ai/rag/sources/sharepoint/sharepoint.ts","lineNumber":720,"sourceCode":"      _deleted: true,\n    }))\n\n  if (docsToDelete.length > 0) {\n    await db.bulkDocs(docsToDelete)\n  }\n}\n\nconst runSharePointSourcesForOperation = async (\n  agentId: string,\n  operationId: string,\n  sourceId: string,\n  signal?: AbortSignal\n): Promise<SharePointSyncResult> => {\n  const lastRunAt = new Date().toISOString()\n  const agent = await agentsSdk.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\n  const knowledgeSource = getSharePointSourcesForOperation(\n    agent,\n    operationId\n  ).find(source => source.id === sourceId)\n  const site = knowledgeSource?.config.site\n  const sourceDatasourceId = knowledgeSource?.config.datasourceId\n  const sourceAuthConfigId = knowledgeSource?.config.authConfigId\n  if (!site) {\n    throw new HTTPError(\n      \"Specified SharePoint site is not connected for this operation\",\n      400\n    )\n  }\n\n  const siteId = site.id\n  const sourceScope = knowledgeSource?.config.scope","sourceCodeStart":702,"sourceCodeEnd":738,"githubUrl":"https://github.com/Budibase/budibase/blob/a81a902e9a8fe55b467d106765f6638f12e35c49/packages/server/src/sdk/workspace/ai/rag/sources/sharepoint/sharepoint.ts#L702-L738","documentation":"syncSharePointSourcesForOperation looks up the agent's SharePoint knowledge sources attached to the given operationId via getSharePointSourcesForOperation and throws this 400 HTTPError when the operation has no SharePoint sources configured. It is an early guard so sync is not attempted for operations without a SharePoint integration.","triggerScenarios":"Calling the sync API (e.g. syncSharePointSourcesForOperation or a route that reaches it) with an operationId that has no SharePoint knowledge source entries on the agent document.","commonSituations":"Sync triggered before the SharePoint source was saved on the agent; operationId typo or an operation from a different agent; the SharePoint source was deleted by another user before sync ran.","solutions":["Add a SharePoint knowledge source to the agent operation before triggering sync","Confirm the operationId belongs to the agent you are syncing (agentsSdk.getOrThrow + inspect its knowledge sources)","Re-check the agent document for concurrent edits that removed the source","Use the agent-level sync entry point which resolves the operationId from sourceId instead"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"const agent = await agentsSdk.getOrThrow(agentId)\nconst sources = getSharePointSourcesForOperation(agent, operationId)\nif (sources.length === 0) {\n  throw new Error(`Operation ${operationId} has no SharePoint sources`)\n}","typeGuard":"const hasSharePointSources = (agent: Agent, operationId: string): boolean =>\n  getSharePointSourcesForOperation(agent, operationId).length > 0","tryCatchPattern":"try {\n  await syncSharePointSourcesForOperation(agentId, operationId, sourceId)\n} catch (err) {\n  if (err instanceof HTTPError && err.status === 400 && err.message === \"SharePoint is not connected for this operation\") {\n    // prompt user to connect a SharePoint source before syncing\n  } else { throw err }\n}","preventionTips":["Only expose the sync action in UI when a SharePoint source is connected","Verify the operationId matches the agent before syncing","Watch for concurrent deletes of the source","Prefer agent-level sync that resolves operationId from sourceId"],"tags":["sharepoint","configuration","sync"],"backgroundTag":"integration-not-configured","analyzedSha":"a81a902e9a8fe55b467d106765f6638f12e35c49","analyzedAt":"2026-08-29T01:03:10.972Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}