Budibase/budibase · error · HTTPError
oAuth config ${id} could not be found
Error message
oAuth config ${id} could not be found What it means
getToken(id) loads the OAuth2 config by id from the workspace DB inside the token cache loader; if no config document exists it throws this 400 HTTPError. It guards the token-fetch path so requests referencing a deleted or unknown OAuth2 config fail fast with a clear message.
Source
Thrown at packages/server/src/sdk/workspace/oauth2/utils.ts:108
}): Promise<{ value: string; ttl: number }> {
const resp = await fetchToken(config)
const jsonResponse = await resp.json()
if (!resp.ok) {
const message = jsonResponse.error_description ?? resp.statusText
throw new Error(`Error fetching oauth2 token: ${message}`)
}
const token = `${jsonResponse.token_type} ${jsonResponse.access_token}`
const ttl = jsonResponse.expires_in ?? -1
return { value: token, ttl }
}
export async function getToken(id: string) {
const token = await cache.withCacheWithDynamicTTL(
cache.CacheKey.OAUTH2_TOKEN(id),
async () => {
const config = await get(id)
if (!config) {
throw new HTTPError(`oAuth config ${id} could not be found`, 400)
}
return fetchAndParseToken(config)
}
)
await trackUsage(id)
return token
}
export async function getTokenFromConfig(
cacheKey: string,
config: {
url: string
clientId: string
clientSecret: string
method: OAuth2CredentialsMethod
grantType: OAuth2GrantType
scope?: stringView on GitHub (pinned to a81a902e9a)
Solutions
- Restore or recreate the OAuth2 config with that id in the workspace
- Update the referencing query/datasource to a valid config id
- Verify the workspace context — the id must exist in the app being served
- Run sdk.workspace.oauth2.fetch() to list valid ids
Example fix
// before
const headers = await getAuthHeaders('oauth2_cfg_wrongid')
// after
const configs = await sdk.workspace.oauth2.fetch()
const config = configs.find(c => c.name === 'my-provider')
if (!config) throw new Error('Configure the OAuth2 provider first')
const headers = await getAuthHeaders(config._id) Defensive patterns
Strategy: validation
Validate before calling
const configs = await sdk.workspace.oauth2.fetch()
const config = configs.find(c => c._id === id)
if (!config) throw new Error(`OAuth2 config '${id}' is not configured in this app`) Type guard
function hasOAuthConfig(
c: OAuth2Config | undefined
): c is OAuth2Config {
return !!c && typeof c._id === "string"
} Try / catch
try {
const headers = await getAuthHeaders(id)
} catch (e) {
if (e instanceof HTTPError && e.status === 400 && /could not be found/.test(e.message)) {
// fall back to unauthenticated request or prompt user to configure OAuth2
} else throw e
} Prevention
- Reference configs by name resolved at runtime instead of hardcoding ids
- Delete or re-point queries that reference configs before removing the config
- Keep exports/imports of apps including their oauth2 config docs
When it happens
Trigger: Any caller of getToken (queries/auth headers/automation steps) supplying an oauth2 config id that does not exist in the workspace: the config was deleted after being referenced by a query/datasource, the id is misspelled, or it belongs to another app's workspace DB.
Common situations: Deleting an OAuth2 config that is still referenced by REST queries; exporting/importing apps without the config docs; hardcoding ids copied from another environment; caching layers holding references to purged configs.
Understand the failure class
Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.
Related errors
- OAuth2 auth config not found
- SharePoint site is not connected for this operation
- OAuth2 config with id '${config._id}' not found.
- OAuth2 config with id '${configId}' not found.
- Error getting account by email ${email}
AI-assisted analysis of Budibase/budibase@a81a902e9a (2026-08-29).
Data as JSON: /api/errors/d56c81d52c1882fc.
Report an issue: GitHub.