{"record":{"id":"f9eb7a90f0d836cb","repo":"Budibase/budibase","slug":"sharepoint-is-not-connected-for-this-workspace","errorCode":null,"errorMessage":"SharePoint is not connected for this workspace","messagePattern":"SharePoint is not connected for this workspace","errorType":"http","errorClass":"HTTPError","httpStatus":400,"severity":"error","filePath":"packages/server/src/sdk/workspace/ai/rag/sources/sharepoint/sharepoint.ts","lineNumber":418,"sourceCode":"  siteId: string,\n  driveId?: string,\n  parentItemId?: string,\n  parentPath = \"\"\n): Promise<FetchAgentKnowledgeSourceEntriesResponse> => {\n  const agent = await agentsSdk.getOrThrow(agentId)\n  const source = getSharePointSourcesForOperation(agent, operationId).find(\n    source => source.config.site.id === siteId\n  )\n  if (!source) {\n    throw new HTTPError(\n      \"SharePoint site is not connected for this operation\",\n      404\n    )\n  }\n\n  const { datasourceId, authConfigId } = source.config\n  if (!datasourceId || !authConfigId) {\n    throw new HTTPError(\"SharePoint is not connected for this workspace\", 400)\n  }\n  const bearerToken = await getSharePointBearerToken(datasourceId, authConfigId)\n  const drives = await listSharePointDrives(bearerToken, siteId)\n  if (!driveId) {\n    const lists = await listSharePointLists(bearerToken, siteId)\n    return {\n      entries: [\n        ...drives.map(\n          (drive): KnowledgeSourceEntry => ({\n            id: `drive:${drive.id}`,\n            name: drive.name,\n            path: drive.name,\n            type: \"drive\",\n            driveId: drive.id,\n            hasChildren: true,\n          })\n        ),\n        ...lists.map(","sourceCodeStart":400,"sourceCodeEnd":436,"githubUrl":"https://github.com/Budibase/budibase/blob/a81a902e9a8fe55b467d106765f6638f12e35c49/packages/server/src/sdk/workspace/ai/rag/sources/sharepoint/sharepoint.ts#L400-L436","documentation":"Thrown by fetchSharePointEntriesForOperation when the matched SharePoint source's config is missing datasourceId or authConfigId. Without these credentials a bearer token cannot be obtained to call the SharePoint API.","triggerScenarios":"Calling fetchSharePointEntriesForOperation where source.config.datasourceId or source.config.authConfigId is null/undefined — i.e. the site was added but its datasource/auth connection was never completed.","commonSituations":"Partially completed SharePoint connection flow, deleted datasource or auth config referenced by a stale source config, or workspace-level SharePoint setup skipped.","solutions":["Complete the SharePoint connection so datasourceId and authConfigId are saved on the source config","Reconnect the site (remove and re-add it as a knowledge source) to regenerate the config","Verify the datasource and auth config still exist in the workspace"],"exampleFix":"// before\nconst entries = await fetchSharePointEntriesForOperation({ agentId, operationId, siteId }) // 400 if unconnected\n// after\nconst source = getSharePointSourcesForOperation(agent, operationId).find(s => s.config.site.id === siteId)\nif (!source?.config.datasourceId || !source?.config.authConfigId) {\n  throw new Error(`Site ${siteId} has no datasource/auth config; reconnect it in the workspace`)\n}\nconst entries = await fetchSharePointEntriesForOperation({ agentId, operationId, siteId })","handlingStrategy":"validation","validationCode":"const agent = await agentsSdk.getOrThrow(agentId)\nconst source = (agent.operations?.find(o => o.id === operationId)?.knowledgeSources || [])\n  .find(s => s.config?.site?.id === siteId)\nif (!source?.config.datasourceId || !source?.config.authConfigId) {\n  throw new Error(`Site ${siteId} is missing datasource/auth configuration`)\n}","typeGuard":"const isSharePointSourceConnected = (source: SharePointKnowledgeSource): boolean =>\n  !!source.config.datasourceId && !!source.config.authConfigId","tryCatchPattern":"try {\n  const entries = await fetchSharePointEntriesForOperation({ agentId, operationId, siteId })\n} catch (err) {\n  if (err instanceof HTTPError && err.status === 400) {\n    // incomplete connection - direct user to reconnect the SharePoint site\n  } else throw err\n}","preventionTips":["Complete the full SharePoint connect flow (datasource + auth config) before saving the source","Reconnect sources after deleting their underlying datasource or auth config","Surface connection status in the UI so unconnected sites are not queried"],"tags":["sharepoint","configuration","missing-credentials"],"backgroundTag":"missing-datasource-credentials","analyzedSha":"a81a902e9a8fe55b467d106765f6638f12e35c49","analyzedAt":"2026-08-29T01:03:10.972Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}