{"record":{"id":"2e5367fec63b33ad","repo":"Budibase/budibase","slug":"automation-did-not-have-a-collect-block","errorCode":null,"errorMessage":"Automation did not have a collect block","messagePattern":"Automation did not have a collect block","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/server/src/automations/steps/triggerAutomationRun.ts","lineNumber":59,"sourceCode":"      }\n\n      const response = await triggers.externalTrigger(\n        automation,\n        { fields: { ...fieldParams }, timeout },\n        { getResponses: true, isTestRun }\n      )\n\n      if (triggers.isAutomationResults(response)) {\n        const isSuccessStatus =\n          response.status === AutomationStatus.SUCCESS ||\n          response.status === AutomationStatus.STOPPED\n        return {\n          success: isSuccessStatus,\n          value: response.steps,\n          status: response.status,\n        }\n      } else {\n        throw new Error(\"Automation did not have a collect block\")\n      }\n    }\n  } else {\n    return {\n      success: false,\n      status: AutomationStatus.ERROR,\n    }\n  }\n}\n","sourceCodeStart":41,"sourceCodeEnd":69,"githubUrl":"https://github.com/Budibase/budibase/blob/a81a902e9a8fe55b467d106765f6638f12e35c49/packages/server/src/automations/steps/triggerAutomationRun.ts#L41-L69","documentation":"`run` in triggerAutomationRun.ts executes a chained/sub-automation and expects the target automation's final step to be a Collect block whose response supplies the returned value and status. When the triggered automation finishes without a collect block, this error is thrown because there is no meaningful result to return to the caller.","triggerScenarios":"Using the 'Run automation' (triggerAutomationRun) step pointing at an automation whose last step is not a Query/Collect block; the sub-automation succeeds but returns no collectable response, so run() throws.","commonSituations":"Refactoring a sub-automation and deleting or moving the Collect block so it is no longer the final step; wiring a parent automation to a child that was designed as a fire-and-forget (row trigger) automation; copying an automation and truncating its steps.","solutions":["Add a Collect block (e.g. a Query step) as the final step of the target automation.","Verify in the builder that the automation selected in the 'Run automation' step ends with the collect-style block.","If the child automation should not return data, change the parent to a fire-and-forget trigger rather than one that expects a response."],"exampleFix":"// before: child automation steps = [createRow]\n// after: child automation steps = [createRow, collect(query)]","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  const result = await triggerAutomationRun({ automationId, fields })\n  return result.value\n} catch (err) {\n  if (err.message === \"Automation did not have a collect block\") {\n    throw new Error(`Target automation '${automationId}' must end with a Collect block to return data`)\n  }\n  throw err\n}","preventionTips":["Ensure every sub-automation invoked via 'Run automation' ends with a Collect/Query block.","Review sub-automations after refactoring steps.","Use fire-and-forget triggers when no response is needed."],"tags":["automation","collect-block","sub-automation","chaining"],"backgroundTag":"automation-missing-collect-block","analyzedSha":"a81a902e9a8fe55b467d106765f6638f12e35c49","analyzedAt":"2026-08-29T01:03:10.972Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}