Budibase/budibase · error · HTTPError

siteId is required

Error message

siteId is required

What it means

Thrown by fetchAgentKnowledgeSourceEntries with HTTP 400 when the siteId query parameter is absent or blank. A SharePoint site must be selected before its drive entries can be listed for the operation.

Source

Thrown at packages/server/src/api/controllers/ai/files.ts:319

    options: await fetchSharePointSitesByDatasourceAuthConfig(
      datasourceId,
      authConfigId
    ),
  }
  ctx.status = 200
}

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
}

View on GitHub (pinned to a81a902e9a)

Solutions

  1. Add a valid siteId query parameter obtained from the site-options endpoint.
  2. Trim and verify query params before building the request URL.
  3. Return the user to the site-selection step when siteId is missing.
  4. Default the UI to the site list when no site has been chosen.

Example fix

// before
await api.get(`/ai/agents/${agentId}/operations/${opId}/knowledge-sources/entries?parentPath=${path}`)
// after
await api.get(`/ai/agents/${agentId}/operations/${opId}/knowledge-sources/entries?siteId=${encodeURIComponent(siteId)}&parentPath=${encodeURIComponent(path)}`)
Defensive patterns

Strategy: validation

Validate before calling

const siteId = new URLSearchParams(query).get("siteId")?.trim()
if (!siteId) throw new Error("siteId is required")
await api.fetchKnowledgeSourceEntries({ agentId, operationId, siteId })

Try / catch

try {
  await api.fetchKnowledgeSourceEntries(params)
} catch (err) {
  if (err.status === 400 && err.message === "siteId is required") {
    // return user to site-selection step
  } else throw err
}

Prevention

When it happens

Trigger: Calling the entries endpoint without ?siteId=; siteId present but only whitespace (trimmed to empty); skipping the site-selection step and jumping straight to folder browsing.

Common situations: Deep links to a folder browser without carrying siteId in state; a picker UI that clears siteId on refresh; automated scripts listing entries without choosing a site first.

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


AI-assisted analysis of Budibase/budibase@a81a902e9a (2026-08-29). Data as JSON: /api/errors/cdb64f4913f31d1b. Report an issue: GitHub.