{"record":{"id":"7940eea85ee57290","repo":"Budibase/budibase","slug":"automation-with-id-automationid-not-found","errorCode":null,"errorMessage":"Automation with ID ${automationId} not found","messagePattern":"Automation with ID (.+?) not found","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/server/src/sdk/workspace/automations/execution.ts","lineNumber":17,"sourceCode":"import { context } from \"@budibase/backend-core\"\nimport { features } from \"@budibase/pro\"\nimport { Automation, AutomationActionStepId } from \"@budibase/types\"\nimport sdk from \"../..\"\nimport * as triggers from \"../../../automations/triggers\"\nimport env from \"../../../environment\"\n\nexport async function trigger(\n  automationId: string,\n  fields: Record<string, any> = {},\n  timeout?: number\n) {\n  const db = context.getWorkspaceDB()\n  const automation = await db.get<Automation>(automationId)\n\n  if (!automation) {\n    throw new Error(`Automation with ID ${automationId} not found`)\n  }\n\n  // Check if automation has APP trigger (required for manual triggering)\n  const triggerType = automation.definition?.trigger?.stepId\n  if (triggerType !== \"APP\") {\n    throw new Error(\n      `Cannot manually trigger automation '${automation.name}'. Only automations with APP trigger type can be manually triggered. This automation has trigger type: ${triggerType}`\n    )\n  }\n\n  let hasCollectStep = sdk.automations.utils.checkForCollectStep(automation)\n  if (hasCollectStep && (await features.isSyncAutomationsEnabled())) {\n    const response = await triggers.externalTrigger(\n      automation,\n      {\n        fields,\n        timeout: timeout ? timeout * 1000 : env.AUTOMATION_THREAD_TIMEOUT,\n      },","sourceCodeStart":1,"sourceCodeEnd":35,"githubUrl":"https://github.com/Budibase/budibase/blob/a81a902e9a8fe55b467d106765f6638f12e35c49/packages/server/src/sdk/workspace/automations/execution.ts#L1-L35","documentation":"Thrown by the `trigger` function in packages/server/src/sdk/workspace/automations/execution.ts when an automation lookup by ID fails. `context.getWorkspaceDB().get<Automation>(automationId)` returned nothing (or the row is falsy), so Budibase aborts before checking trigger types. It protects callers from proceeding with an undefined automation document.","triggerScenarios":"Calling the manual trigger path (e.g. POST /automations/{id}/trigger or sdk.automations.execution.trigger(id)) with an automation ID that does not exist in the workspace DB — deleted automation, typo'd ID, ID from a different app/workspace, or a prod/dev database mismatch.","commonSituations":"Developers copy an automation ID from a dev environment and call the API against prod; automations deleted by another user while a UI client still references them; using the internal _id from an export instead of the live document ID; passing an automation ID to the wrong app's API endpoint.","solutions":["Verify the automation ID exists: GET /api/automations in the target workspace and match the _id","Confirm you are calling the correct app/workspace URL and that dev vs prod deployment matches","Re-create the automation if it was deleted, and use the new ID","If using the SDK, ensure context.getWorkspaceDB() is bound to the workspace that owns the automation"],"exampleFix":"// before\nawait sdk.automations.execution.trigger(\"auto_abcdef\")\n// after\nconst automations = await sdk.automations.fetch()\nconst target = automations.find(a => a._id === \"auto_abcdef\")\nif (!target) throw new Error(`Automation auto_abcdef not found in this workspace`)\nawait sdk.automations.execution.trigger(target._id!)","handlingStrategy":"validation","validationCode":"const exists = (await sdk.automations.fetch()).some(a => a._id === automationId)\nif (!exists) throw new Error(`Automation ${automationId} missing`)","typeGuard":"function isAutomation(a: Automation | undefined): a is Automation {\n  return !!a && typeof a._id === \"string\"\n}","tryCatchPattern":"try {\n  await sdk.automations.execution.trigger(id)\n} catch (err: any) {\n  if (err.message.includes(\"not found\")) {\n    // refetch automations and correct ID\n  } else {\n    throw err\n  }\n}","preventionTips":["Resolve automation IDs dynamically from the API","Confirm dev/prod environment alignment before triggering","Log the workspace/app alongside IDs to catch cross-app usage"],"tags":["automation","not-found","database"],"backgroundTag":"resource-not-found","analyzedSha":"a81a902e9a8fe55b467d106765f6638f12e35c49","analyzedAt":"2026-08-29T01:03:10.972Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}