Budibase/budibase · error · HTTPError
driveId is required with parentItemId
Error message
driveId is required with parentItemId
What it means
Thrown by fetchAgentKnowledgeSourceEntries with HTTP 400 when parentItemId is supplied without driveId. Listing children of a SharePoint item requires knowing which drive the item belongs to.
Source
Thrown at packages/server/src/api/controllers/ai/files.ts:325
}
export async function fetchAgentKnowledgeSourceEntries(
ctx: UserCtx<
void,
FetchAgentKnowledgeSourceEntriesResponse,
{ agentId: string; operationId: string }
>
) {
const { agentId, operationId } = ctx.params
const siteId = String(ctx.query.siteId || "").trim()
if (!siteId) {
throw new HTTPError("siteId is required", 400)
}
const driveId = String(ctx.query.driveId || "").trim() || undefined
const parentItemId = String(ctx.query.parentItemId || "").trim() || undefined
const parentPath = String(ctx.query.parentPath || "").trim()
if (parentItemId && !driveId) {
throw new HTTPError("driveId is required with parentItemId", 400)
}
ctx.body = await sdk.ai.rag.fetchSharePointEntriesForOperation(
agentId,
operationId,
siteId,
driveId,
parentItemId,
parentPath
)
ctx.status = 200
}
export async function resetAgentKnowledgeBaseStore(
ctx: UserCtx<void, void, { agentId: string; operationId: string }>
) {
const { agentId, operationId } = ctx.params
const knowledgeBase = await sdk.ai.rag.ensureKnowledgeBaseForOperation(
agentId,View on GitHub (pinned to a81a902e9a)
Solutions
- Always include driveId in the query when parentItemId is provided.
- Keep site/drive/folder selection state together in the picker UI.
- Clear parentItemId whenever driveId changes to avoid inconsistent requests.
- Add client-side validation mirroring the server's parentItemId+driveId rule.
Example fix
// before
const qs = new URLSearchParams({ siteId, parentItemId })
// after
const qs = new URLSearchParams({ siteId, parentItemId })
if (parentItemId) qs.set("driveId", driveId) Defensive patterns
Strategy: validation
Validate before calling
if (parentItemId && !driveId) throw new Error("driveId is required with parentItemId")
await api.fetchKnowledgeSourceEntries({ agentId, operationId, siteId, driveId, parentItemId }) Try / catch
try {
await api.fetchKnowledgeSourceEntries(params)
} catch (err) {
if (err.status === 400 && err.message.includes("driveId is required")) {
// fall back to drive listing or reselect drive
} else throw err
} Prevention
- Always carry driveId forward once a drive is selected; include it with every nested-item request.
- Track site/drive/folder selection state together, not independently.
- Clear parentItemId when driveId changes.
- Add client-side validation mirroring the server's parentItemId+driveId rule.
When it happens
Trigger: Browsing into a folder (parentItemId set) after losing the driveId query param; navigation state that tracks parentItemId but drops driveId; bookmarks/links built with incomplete query params.
Common situations: Picker UIs where drive selection is optional but folder browsing is attempted anyway; stale browser back/forward entries missing driveId; scripts paginating with parentItemId only.
Understand the failure class
Background: Missing required parameter errors: what 'X is required' and 'the required X param is missing' mean, and how to fix them — this error's family across 27 libraries.
Related errors
- datasourceId and authConfigId are required
- siteId is required
- Specified SharePoint site is not connected for this operatio
- Error getting status
- Invalid bookmark query
AI-assisted analysis of Budibase/budibase@a81a902e9a (2026-08-29).
Data as JSON: /api/errors/f976a1d419cc5bcb.
Report an issue: GitHub.