Budibase/budibase · error
Koa context must be supplied to logout.
Error message
Koa context must be supplied to logout.
What it means
Same failure mode as errorIndex 3 but raised at connection.ts:686 inside fetchSharePointListDocument's item-paging loop: GET /sites/{siteId}/lists/{listId}/items?$expand=fields (or a nextLink page) returned a non-ok status other than 401/403, after the built-in retry pass.
Source
Thrown at packages/backend-core/src/auth/auth.ts:191
}
await db.put(dbUser)
await invalidateUser(userId)
} catch (e) {
console.error("Could not update OAuth details for current user", e)
}
}
/**
* Logs a user out from budibase. Re-used across account portal and builder.
*/
export async function platformLogout(opts: PlatformLogoutOpts) {
const ctx = opts.ctx
const userId = opts.userId
const keepActiveSession = opts.keepActiveSession
if (!ctx) throw new Error("Koa context must be supplied to logout.")
const currentSession = getCookie<SessionCookie>(ctx, Cookie.Auth)
let sessions = await getSessionsForUser(userId)
if (currentSession && keepActiveSession) {
sessions = sessions.filter(
session => session.sessionId !== currentSession.sessionId
)
} else {
// clear cookies
clearCookie(ctx, Cookie.Auth)
}
const sessionIds = sessions.map(({ sessionId }) => sessionId)
await invalidateSessions(userId, { sessionIds, reason: "logout" })
await events.auth.logout(ctx.user?.email)
await userCache.invalidateUser(userId)
}View on GitHub (pinned to a81a902e9a)
Solutions
- Check the status in the message: 404 → re-select the list (it no longer exists at that ID).
- For 429, reschedule the sync; Graph throttling on large lists is common — reduce $top or sync off-peak.
- For 400, verify siteId/listId are raw Graph resource IDs.
- Retry after confirming Graph service health; transient 5xx are retried 3 times already.
Defensive patterns
Strategy: retry
Validate before calling
// Confirm list still exists before streaming items
const list = await graph(`/sites/${siteId}/lists/${listId}?$select=id`)
if (!list?.id) throw new Error("SharePoint list no longer exists") Type guard
const isTransientGraphError = (e: unknown): boolean => {
const m = /\((\d+)\)\s*$/.exec(String((e as Error)?.message))
return m ? ["429", "500", "502", "503", "504"].includes(m[1]) : false
} Try / catch
try {
await fetchSharePointListDocument(token, siteId, listId)
} catch (e) {
if (isTransientGraphError(e)) {
await new Promise(r => setTimeout(r, 30_000))
return fetchSharePointListDocument(token, siteId, listId)
}
throw e
} Prevention
- Schedule large list syncs off-peak to reduce 429 throttling.
- Re-verify list existence at the start of each sync run.
- Wrap syncs in your own retry layer for 429/5xx beyond the built-in 3 attempts.
- Keep raw Graph list IDs; never pass URLs as IDs.
When it happens
Trigger: The list items endpoint returns 404 (list deleted), 400 (bad query/listId), 429 (throttled past retries), or 5xx while streaming rows into the CSV.
Common situations: List deleted or moved to recycle bin after configuration; list exceeding Graph throttling limits during large syncs; listId copied from a non-Graph source; intermittent Graph 5xx.
Related errors
- OIDC Config contents invalid
- Failed to fetch SharePoint drive item (${response.status})
- Failed to download SharePoint file (${response.status})
- Error getting account by email ${email}
- Error getting account by tenantId ${tenantId}
AI-assisted analysis of Budibase/budibase@a81a902e9a (2026-08-29).
Data as JSON: /api/errors/7c0caa2d1ad006d7.
Report an issue: GitHub.