{"record":{"id":"ba5289b63bad800c","repo":"Budibase/budibase","slug":"specified-sharepoint-site-is-not-connected-for-thi-ba5289","errorCode":null,"errorMessage":"Specified SharePoint site is not connected for this operation","messagePattern":"Specified SharePoint site 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":731,"sourceCode":"  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\n  if (\n    !sourceScope ||\n    (sourceScope.mode !== SharePointScopeMode.ALL &&\n      sourceScope.mode !== SharePointScopeMode.SELECTED)\n  ) {\n    throw new HTTPError(\n      \"This SharePoint source uses an outdated configuration. Delete and reconnect it to continue syncing.\",\n      400\n    )\n  }\n","sourceCodeStart":713,"sourceCodeEnd":749,"githubUrl":"https://github.com/Budibase/budibase/blob/a81a902e9a8fe55b467d106765f6638f12e35c49/packages/server/src/sdk/workspace/ai/rag/sources/sharepoint/sharepoint.ts#L713-L749","documentation":"During a per-source sync, the code finds the knowledge source matching sourceId within the operation's SharePoint sources and reads source.config.site. If the source exists but has no site configured, this 400 HTTPError is thrown, meaning the source record is present but incomplete — no SharePoint site was saved on it.","triggerScenarios":"Calling sync with a sourceId whose knowledge source config lacks the site field — e.g. the source was created/validated without completing the site selection step.","commonSituations":"Source created by an older builder version before site config was required; partially completed connection wizard; config corrupted or manually edited; config site key missing after a schema/version change.","solutions":["Reconnect the SharePoint source via the builder so config.site is saved","Delete and re-add the knowledge source to the operation","Inspect the agent document to confirm config.site (and datasourceId/authConfigId) are populated","Check for schema/version drift between the saved source config and the current expected shape"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"const agent = await agentsSdk.getOrThrow(agentId)\nconst source = getSharePointSourcesForOperation(agent, operationId).find(s => s.id === sourceId)\nif (!source?.config?.site?.id) {\n  throw new Error(`Source ${sourceId} has no site configured`)\n}","typeGuard":"const hasSiteConfig = (\n  source: AgentSharePointKnowledgeSource | undefined\n): source is AgentSharePointKnowledgeSource & {\n  config: { site: { id: string } }\n} => typeof source?.config?.site?.id === \"string\"","tryCatchPattern":"try {\n  await syncSharePointSourceForAgent(agentId, sourceId)\n} catch (err) {\n  if (err instanceof HTTPError && err.status === 400 && err.message.includes(\"not connected for this operation\")) {\n    // guide user to reconnect the source\n  } else { throw err }\n}","preventionTips":["Require site selection to be completed before saving the source","Validate source config shape at save time","Re-save sources after upgrading schema","Detect and flag sources with missing site in admin tooling"],"tags":["sharepoint","configuration","validation"],"backgroundTag":"incomplete-integration-config","analyzedSha":"a81a902e9a8fe55b467d106765f6638f12e35c49","analyzedAt":"2026-08-29T01:03:10.972Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}