Budibase/budibase · error · HTTPError
Failed to fetch SharePoint sites (${response.status})
Error message
Failed to fetch SharePoint sites (${response.status}) What it means
Generic failure path of fetchSitesPage: any non-OK Graph response that is not 401 (and not a 403/400-with-description special case) becomes an HTTPError 400 with message 'Failed to fetch SharePoint sites (<status>)'. The original HTTP status is embedded in the message.
Source
Thrown at packages/server/src/sdk/workspace/ai/knowledgeSources/sharepoint/connection.ts:250
// noop
}
console.error("Failed to fetch SharePoint sites (app token)", {
status: response.status,
errorCode,
hasErrorDescription: !!errorDescription,
})
let errorMessage = `Failed to fetch SharePoint sites (${response.status})`
if (response.status === 401) {
errorMessage =
"Authentication failed with Microsoft Graph. Verify SharePoint application credentials and try again."
throw new HTTPError(errorMessage, 401)
} else if (response.status === 403) {
errorMessage =
"Access denied by Microsoft Graph. Ensure SharePoint application permissions are granted."
} else if (response.status === 400 && errorDescription) {
errorMessage = `Microsoft Graph rejected the SharePoint search request: ${errorDescription}`
}
throw new HTTPError(errorMessage, 400)
}
return (await response.json()) as {
value?: Array<{
id?: string
displayName?: string
name?: string
webUrl?: string
}>
"@odata.nextLink"?: string
}
}
for (let page = 0; nextLink && page < 50; page++) {
const payload = await fetchSitesPage(nextLink)
for (const site of payload.value || []) {
if (!site?.id) {
continue
}View on GitHub (pinned to a81a902e9a)
Solutions
- Read the HTTP status embedded in the message and retry later for 429/5xx (the request already goes through requestWithRetries).
- For repeated failures, check the Microsoft Graph service health status page.
- Inspect server logs — errorCode and description presence are logged before the throw.
- Reduce page size ($top) or frequency of site fetches if throttled.
Defensive patterns
Strategy: retry
Try / catch
try {
await fetchSharePointSitesByDatasourceAuthConfig(datasourceId, authConfigId)
} catch (err) {
const status = Number(err?.message?.match(/\((\d+)\)$/)?.[1])
if (status === 429 || status >= 500) {
// transient: back off and retry
}
throw err
} Prevention
- Respect Graph throttling limits; reduce $top page size and call frequency.
- Schedule large site enumerations off-peak.
- Monitor Microsoft Graph service health for outages.
- Rely on requestWithRetries for transient failures rather than adding ad-hoc retries.
When it happens
Trigger: Graph responds with a status like 429 (throttling), 500/503 (service unavailable), or a 403/400 without the specific payloads the special cases expect; also any unexpected status code.
Common situations: Graph API throttling under heavy site enumeration; transient Microsoft service outages; malformed search requests rejected with unusual codes; network proxies returning non-JSON bodies that defeat the error-description parsing.
Related errors
- Error getting account by tenantId ${tenantId}
- Error getting account by email ${email}
- Error getting status
- OIDC Config contents invalid
- Could not refresh OAuth Token
AI-assisted analysis of Budibase/budibase@a81a902e9a (2026-08-29).
Data as JSON: /api/errors/964e6d3b24a3eb10.
Report an issue: GitHub.