Budibase/budibase · error · HTTPError
SharePoint auth config not found.
Error message
SharePoint auth config not found.
What it means
readConnection loads the SharePoint datasource and locates the OAuth2 auth config by id. If sdk.datasources.get throws (datasource does not exist, deleted, or DB error), the error is swallowed and re-thrown as 'SharePoint auth config not found.' with status 400. Note this same message covers the datasource-not-found case, not just a missing auth config.
Source
Thrown at packages/server/src/sdk/workspace/ai/knowledgeSources/sharepoint/connection.ts:168
nextUrl.hostname === SHAREPOINT_API_BASE_URL.hostname &&
nextUrl.port === SHAREPOINT_API_BASE_URL.port &&
(nextUrl.pathname === SHAREPOINT_API_BASE_URL.pathname ||
nextUrl.pathname.startsWith(`${SHAREPOINT_API_BASE_URL.pathname}/`))
)
} catch {
return false
}
}
const readConnection = async (
datasourceId: string,
authConfigId: string
): Promise<OAuth2RestAuthConfigWithTokenCache> => {
let datasource: Datasource
try {
datasource = await sdk.datasources.get(datasourceId)
} catch {
throw new HTTPError("SharePoint auth config not found.", 400)
}
const authConfigs = datasource.config?.authConfigs as
| OAuth2RestAuthConfigWithTokenCache[]
| undefined
const authConfig = authConfigs?.find(config => config._id === authConfigId)
if (!authConfig) {
throw new HTTPError("SharePoint auth config not found.", 400)
}
if (!isOAuth2ClientCredentialsAuthConfig(authConfig)) {
throw new HTTPError(
"SharePoint requires an OAuth2 client credentials auth config.",
400
)
}
if (!authConfig.url || !authConfig.clientId) {
throw new HTTPError(
"OAuth2 auth config is missing token URL or client ID.",
400View on GitHub (pinned to a81a902e9a)
Solutions
- Verify the datasourceId exists in the workspace (datasources API) and has not been deleted.
- Check datasource.config.authConfigs contains an entry whose _id equals the authConfigId being used.
- Re-link the SharePoint knowledge source to a current datasource + auth config pair.
Defensive patterns
Strategy: try-catch
Validate before calling
const datasource = await sdk.datasources.get(datasourceId) // throws if missing
const authConfig = datasource.config?.authConfigs?.find(c => c._id === authConfigId)
if (!authConfig) {
throw new Error(`Auth config ${authConfigId} missing on datasource ${datasourceId}`)
} Try / catch
try {
await fetchSharePointSitesByDatasourceAuthConfig(datasourceId, authConfigId)
} catch (err) {
if (err instanceof HTTPError && err.message === "SharePoint auth config not found.") {
// prompt user to re-configure the SharePoint datasource/auth config
}
throw err
} Prevention
- When deleting a datasource, also delete or re-link any SharePoint knowledge sources referencing it.
- Store datasourceId + authConfigId together and validate the pair exists before saving a knowledge source.
- Avoid copying knowledge source configs between apps where ids do not resolve.
When it happens
Trigger: Calling connection()/getSharePointBearerToken()/fetchSharePointSitesByDatasourceAuthConfig with a datasourceId that no longer exists, or an authConfigId that is not present in datasource.config.authConfigs.
Common situations: The REST datasource was deleted or its auth config removed while a SharePoint knowledge source still references the ids; copying a knowledge source between apps; stale authConfigId after the datasource was re-configured.
Related errors
- OAuth2 auth config is missing token URL or client ID.
- Error getting account by email ${email}
- datasourceId and authConfigId are required
- siteId is required
- driveId is required with parentItemId
AI-assisted analysis of Budibase/budibase@a81a902e9a (2026-08-29).
Data as JSON: /api/errors/19e815856a502f25.
Report an issue: GitHub.