{"record":{"id":"2133a00fba5241c3","repo":"Budibase/budibase","slug":"operation-not-found","errorCode":null,"errorMessage":"Operation not found","messagePattern":"Operation not found","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/builder/src/stores/portal/agents.ts","lineNumber":138,"sourceCode":"\n  private getAgentOrThrow = (agentId: string) => {\n    const agent = get(this.store).agents.find(\n      candidate => candidate._id === agentId\n    )\n    if (!agent) {\n      throw new Error(\"Agent not found\")\n    }\n    return agent\n  }\n\n  private updateOperation = async (\n    agentId: string,\n    operationId: string,\n    updater: (operation: AgentOperation) => AgentOperation\n  ) => {\n    const operation = this.getAgentOperation(agentId, operationId)\n    if (!operation) {\n      throw new Error(\"Operation not found\")\n    }\n    const updated = updater(operation)\n    return await this.updateAgentOperation(agentId, operationId, {\n      name: updated.name,\n      live: updated.live,\n      promptInstructions: updated.promptInstructions,\n      enabledTools: updated.enabledTools,\n      allowKnowledgeSourceDownload: updated.allowKnowledgeSourceDownload,\n    })\n  }\n\n  private replaceAgentInStore = (updated: Agent) => {\n    this.update(state => {\n      const index = state.agents.findIndex(a => a._id === updated._id)\n      if (index !== -1) {\n        state.agents[index] = updated\n      }\n      return state","sourceCodeStart":120,"sourceCodeEnd":156,"githubUrl":"https://github.com/Budibase/budibase/blob/a81a902e9a8fe55b467d106765f6638f12e35c49/packages/builder/src/stores/portal/agents.ts#L120-L156","documentation":"updateOperation resolves the agent operation via getAgentOperation (which itself validates the agent exists) and throws if the specific operationId is not found on that agent. This guards the mutation and subsequent API update against operating on a nonexistent operation.","triggerScenarios":"Calling an operation-updating method (e.g. rename, toggle live, update prompt) with an operationId that is not present on the agent identified by agentId.","commonSituations":"Operation deleted concurrently in another tab; stale id after the agent's operations were replaced; mixing up ids between agents; UI list not refreshed after deletion.","solutions":["Verify the operationId belongs to the given agentId","Refresh agent data before updating the operation","Handle concurrent deletion — re-fetch and update the UI","Check you are not passing the agent id where the operation id is expected"],"exampleFix":"// before\nawait agents.renameOperation(agentId, opId, \"New name\")\n// after\nconst agent = get(agents).agents.find(a => a._id === agentId)\nif (agent?.operations?.some(o => o.id === opId)) {\n  await agents.renameOperation(agentId, opId, \"New name\")\n}","handlingStrategy":"try-catch","validationCode":"const agent = get(agents).agents.find(a => a._id === agentId)\nconst op = agent?.operations?.find(o => o.id === operationId)\nif (!op) {\n  await agents.fetch()\n  return\n}","typeGuard":null,"tryCatchPattern":"try {\n  await agents.updateOperation(agentId, operationId, updater)\n} catch (e) {\n  if (e.message === \"Operation not found\") {\n    await agents.fetch() // resync; operation may have been deleted\n  } else throw e\n}","preventionTips":["Ensure operation ids come from the same agent record you pass","Refresh agent data after any concurrent modification","Don't confuse agent ids with operation ids","Handle deleted operations in the UI instead of retaining stale rows"],"tags":["builder","agents","not-found","state"],"backgroundTag":"entity-not-found","analyzedSha":"a81a902e9a8fe55b467d106765f6638f12e35c49","analyzedAt":"2026-08-29T01:03:10.972Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}