Budibase/budibase · critical · Error
No Microsoft datasource configuration found
Error message
No Microsoft datasource configuration found
What it means
getMicrosoftConfig validates that MICROSOFT_CLIENT_ID and MICROSOFT_CLIENT_SECRET are set in the environment; if either is missing it throws this Error. The returned config also defaults MICROSOFT_TENANT_ID to 'common'.
Source
Thrown at packages/server/src/api/controllers/ai/sharepointAuth.ts:20
import { DatasourceAuthCookie, UserCtx } from "@budibase/types"
const DEFAULT_SCOPE = env.RAG_SHAREPOINT_DEFAULT_SCOPE
const STATE_CACHE_TTL_SECONDS = 600
const MICROSOFT_PROVIDER = "microsoft"
const MICROSOFT_GRAPH_BASE = "https://graph.microsoft.com/v1.0"
const TOKEN_EXPIRY_BUFFER_SECONDS = 60
export const calculateBufferedTokenExpiry = (expiresInSeconds: number) => {
const bufferedTtlSeconds = Math.max(
expiresInSeconds - TOKEN_EXPIRY_BUFFER_SECONDS,
0
)
return Date.now() + bufferedTtlSeconds * 1000
}
const getMicrosoftConfig = () => {
if (!env.MICROSOFT_CLIENT_ID || !env.MICROSOFT_CLIENT_SECRET) {
throw new Error("No Microsoft datasource configuration found")
}
return {
clientId: env.MICROSOFT_CLIENT_ID,
clientSecret: env.MICROSOFT_CLIENT_SECRET,
tenantId: env.MICROSOFT_TENANT_ID || "common",
}
}
const appendQueryParam = (path: string, key: string, value: string) => {
const base = "http://localhost"
const url = new URL(path, base)
url.searchParams.set(key, value)
const qs = url.searchParams.toString()
return `${url.pathname}${qs ? `?${qs}` : ""}`
}
export async function startSharePointAuth(ctx: UserCtx<void, void>) {
const appId = String(ctx.query.appId || "").trim()View on GitHub (pinned to a81a902e9a)
Solutions
- Set MICROSOFT_CLIENT_ID and MICROSOFT_CLIENT_SECRET in the server's environment and restart.
- Optionally set MICROSOFT_TENANT_ID (defaults to 'common' for multi-tenant apps).
- Verify via deployment config/secrets manager that the vars are injected into the correct service container.
Example fix
// before (env) # MICROSOFT_CLIENT_ID not set // after (env) MICROSOFT_CLIENT_ID=your-app-client-id MICROSOFT_CLIENT_SECRET=your-app-client-secret MICROSOFT_TENANT_ID=your-tenant-id
Defensive patterns
Strategy: validation
Validate before calling
if (!process.env.MICROSOFT_CLIENT_ID || !process.env.MICROSOFT_CLIENT_SECRET) {
throw new Error('Set MICROSOFT_CLIENT_ID and MICROSOFT_CLIENT_SECRET before using SharePoint auth')
} Type guard
function microsoftEnvIsConfigured(env: typeof import('@budibase/backend-core').env): boolean {
return Boolean(env.MICROSOFT_CLIENT_ID && env.MICROSOFT_CLIENT_SECRET)
} Try / catch
try {
await startSharePointAuth(ctx)
} catch (e) {
if (e.message === 'No Microsoft datasource configuration found') {
// surface a config-required message to the admin
} else throw e
} Prevention
- Add a startup health check that fails fast when Microsoft env vars are missing.
- Keep server and worker env configs in sync via a shared .env/secret template.
- Document required MICROSOFT_* variables in deployment docs.
When it happens
Trigger: Any SharePoint OAuth flow (start or callback) executed on a server that lacks MICROSOFT_CLIENT_ID or MICROSOFT_CLIENT_SECRET env vars, including the OAuth callback path in completeSharePointAuth which calls getMicrosoftConfig to exchange the code.
Common situations: Fresh deployment without Microsoft credentials provisioned; self-hosted install missing env entries in .env; secrets configured for the worker but not the server (or vice versa); typo in env var name.
Understand the failure class
Background: "environment variable is not set" and "Missing keys in environment" errors: what missing required env var messages mean and how to fix them — this error's family across 28 libraries.
Related errors
- Microsoft OAuth callback is missing state
- Microsoft OAuth state is invalid or expired
- Microsoft OAuth authorization failed
- Microsoft OAuth callback is missing the authorization code
- Failed to exchange Microsoft OAuth code
AI-assisted analysis of Budibase/budibase@a81a902e9a (2026-08-29).
Data as JSON: /api/errors/aec5fec95afff946.
Report an issue: GitHub.