Budibase/budibase · error · HTTPError

Operation not found for this agent

Error message

Operation not found for this agent

What it means

Thrown by getOperationOrThrow when the requested operationId does not exist on the given agent's operations array. Used by SharePoint source lookups to ensure the operation belongs to the agent.

Source

Thrown at packages/server/src/sdk/workspace/ai/rag/sources/sharepoint/sharepoint.ts:134

export const getSharePointFileDedupKey = ({
  siteId,
  driveId,
  itemId,
}: {
  siteId: string
  driveId: string
  itemId: string
}) => `${siteId}:${driveId}:${itemId}`

const getOperationOrThrow = (
  agent: Agent,
  operationId: string
): AgentOperation => {
  const operation = agent.operations?.find(
    operation => operation.id === operationId
  )
  if (!operation) {
    throw new HTTPError("Operation not found for this agent", 404)
  }
  return operation
}

const getSharePointSourcesForOperation = (agent: Agent, operationId: string) =>
  (getOperationOrThrow(agent, operationId).knowledgeSources || []).filter(
    source => source.type === "sharepoint"
  )

const getSharePointSyncRunStatus = (
  synced: number,
  failed: number
): AgentKnowledgeSourceSyncRunStatus => {
  if (failed === 0) {
    return AgentKnowledgeSourceSyncRunStatus.SUCCESS
  }
  if (synced === 0) {
    return AgentKnowledgeSourceSyncRunStatus.FAILED

View on GitHub (pinned to a81a902e9a)

Solutions

  1. Re-fetch the agent and enumerate agent.operations to get a valid operation id
  2. Update any stored operationId references after deleting/re-creating operations
  3. Verify you are passing the id, not a name or index

Example fix

// before
await fetchSharePointEntriesForOperation({ agentId, operationId: staleId }) // 404
// after
const agent = await agentsSdk.getOrThrow(agentId)
const opId = agent.operations?.[0]?.id
if (!opId) throw new Error('Agent has no operations configured')
await fetchSharePointEntriesForOperation({ agentId, operationId: opId })
Defensive patterns

Strategy: validation

Validate before calling

const agent = await agentsSdk.getOrThrow(agentId)
const op = agent.operations?.find(o => o.id === operationId)
if (!op) throw new Error(`Operation ${operationId} not found on agent ${agentId}`)

Type guard

const agentHasOperation = (agent: Agent, operationId: string): boolean =>
  !!agent.operations?.some(o => o.id === operationId)

Try / catch

try {
  const entries = await fetchSharePointEntriesForOperation({ agentId, operationId, siteId })
} catch (err) {
  if (err instanceof HTTPError && err.status === 404) {
    // re-fetch agent operations and pick a valid operationId
  } else throw err
}

Prevention

When it happens

Trigger: Calling getSharePointSourcesForOperation (or fetchSharePointEntriesForOperation) with an operationId that is not present in agent.operations.

Common situations: Hardcoded/stale operation IDs, an operation deleted after being saved elsewhere, or mixing operations between agents.

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


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