Budibase/budibase · error · HTTPError
Specified SharePoint site is not connected for this agent
Error message
Specified SharePoint site is not connected for this agent
What it means
syncSharePointSourceForAgent (agent-level entry point) resolves which operation of the agent owns the given sourceId using findOperationIdForKnowledgeSource. If no operation references that sourceId, this 400 HTTPError is thrown — the agent has no SharePoint knowledge source with that id.
Source
Thrown at packages/server/src/sdk/workspace/ai/rag/sources/sharepoint/sharepoint.ts:1355
abortController.signal
)
} finally {
clearTimeout(timeout)
}
}
)
return result
}
export const syncSharePointSourcesForAgent = async (
agentId: string,
sourceId: string
): Promise<SharePointSyncResult> => {
const agent = await agentsSdk.getOrThrow(agentId)
const operationId = findOperationIdForKnowledgeSource(agent, sourceId)
if (!operationId) {
throw new HTTPError(
"Specified SharePoint site is not connected for this agent",
400
)
}
return await syncSharePointSourcesForOperation(agentId, operationId, sourceId)
}
export const deleteSharePointFilesForOperationSite = async (
agentId: string,
operationId: string,
siteId: string
) => {
const files = await listFilesForOperation(agentId, operationId)
const fileIdsToDelete = files
.filter(
file =>
(file.source?.type === KnowledgeBaseFileSourceType.SHAREPOINT_SITE ||View on GitHub (pinned to a81a902e9a)
Solutions
- List the agent's knowledge sources and use a valid sourceId that is attached to an operation
- Re-add the SharePoint source to the agent if it was deleted, then sync the new sourceId
- Confirm you are calling the sync for the correct agentId that owns the source
- Refresh UI/client state so it reflects the agent's current sources
Example fix
// before await syncSharePointSourceForAgent(agentId, staleSourceId) // after const agent = await agentsSdk.getOrThrow(agentId) const validId = agent.operations.flatMap(o => o.knowledgeSources ?? []).find(s => s.type === "sharepoint")?.id if (validId) await syncSharePointSourceForAgent(agentId, validId)
Defensive patterns
Strategy: validation
Validate before calling
const agent = await agentsSdk.getOrThrow(agentId)
const opId = findOperationIdForKnowledgeSource(agent, sourceId)
if (!opId) {
throw new Error(`Source ${sourceId} is not attached to any operation on agent ${agentId}`)
} Type guard
const isSourceOnAgent = (agent: Agent, sourceId: string): boolean => findOperationIdForKnowledgeSource(agent, sourceId) !== null
Try / catch
try {
await syncSharePointSourceForAgent(agentId, sourceId)
} catch (err) {
if (err instanceof HTTPError && err.status === 400 && err.message.includes("not connected for this agent")) {
// refresh source list and pick a valid sourceId
} else { throw err }
} Prevention
- Fetch the agent's current source list before syncing; never use cached sourceIds
- Scope UI state per agent so ids cannot cross over
- Handle source deletion events by invalidating stored ids
- Confirm agentId and sourceId pairing in client calls
When it happens
Trigger: Calling the per-agent sync API with a sourceId that is not attached to any operation on the agent (wrong id, deleted source, or sourceId from a different agent).
Common situations: Client cached a sourceId after the source was deleted; copying sourceIds between agents; typo/stale id stored in UI state; agent document updated concurrently.
Related errors
- SharePoint is not connected for this operation
- Error getting account by email ${email}
- Error getting account by tenantId ${tenantId}
- Error getting status
- OIDC Config contents invalid
AI-assisted analysis of Budibase/budibase@a81a902e9a (2026-08-29).
Data as JSON: /api/errors/1cf4b595d9b1de33.
Report an issue: GitHub.