{"record":{"id":"ff5ba63660df2450","repo":"Budibase/budibase","slug":"automation-trigger-is-not-an-email-trigger","errorCode":null,"errorMessage":"Automation trigger is not an email trigger","messagePattern":"Automation trigger is not an email trigger","errorType":"http","errorClass":"HTTPError","httpStatus":400,"severity":"error","filePath":"packages/server/src/api/controllers/automation.ts","lineNumber":252,"sourceCode":"    throw new HTTPError(\n      \"Automation ID is required to test a saved password\",\n      400\n    )\n  }\n\n  const automation = await context\n    .getWorkspaceDB()\n    .tryGet<Automation>(automationId)\n  if (!automation) {\n    throw new HTTPError(\"Automation not found\", 404)\n  }\n\n  const trigger = automation.definition.trigger\n  if (!trigger) {\n    throw new HTTPError(\"No trigger found for automation\", 400)\n  }\n  if (!isEmailTrigger(trigger)) {\n    throw new HTTPError(\"Automation trigger is not an email trigger\", 400)\n  }\n  if (!trigger.inputs.password) {\n    throw new HTTPError(\"IMAP password is required\", 400)\n  }\n\n  const stored = trigger.inputs\n  const connectionMatches =\n    emailInputs.host === stored.host &&\n    emailInputs.port === stored.port &&\n    emailInputs.username === stored.username &&\n    emailInputs.secure === stored.secure\n  if (!connectionMatches) {\n    throw new HTTPError(\n      \"IMAP password is required when connection details change\",\n      400\n    )\n  }\n","sourceCodeStart":234,"sourceCodeEnd":270,"githubUrl":"https://github.com/Budibase/budibase/blob/a81a902e9a8fe55b467d106765f6638f12e35c49/packages/server/src/api/controllers/automation.ts#L234-L270","documentation":"The automation has a trigger, but it is not an email trigger type. hydrateEmailConnectionPassword only applies to IMAP/email triggers, since only they store a password in their inputs; any other trigger type is rejected with HTTP 400.","triggerScenarios":"Calling testEmailConnection with an automationId whose trigger is e.g. a row-created, webhook, or schedule trigger instead of an email trigger.","commonSituations":"Passing the wrong automationId (pointing at a non-email automation); UI state referencing an automation whose trigger type was changed after load.","solutions":["Pass the automationId of an automation with an email (IMAP) trigger","Change the automation's trigger to an email trigger if that was intended","Provide the plaintext password directly instead of relying on the saved trigger"],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":"if (automation.definition?.trigger && !automation.definition.trigger.event?.includes('EMAIL')) {\n  throw new Error('testEmailConnection requires an email-trigger automation')\n}","typeGuard":"function isEmailTrigger(t: unknown): t is EmailTrigger {\n  return typeof t === 'object' && t !== null && 'inputs' in t && typeof (t as { inputs: unknown }).inputs === 'object'\n}","tryCatchPattern":"try {\n  await testEmailConnection({ emailInputs, automationId })\n} catch (e) {\n  if (e.status === 400 && e.message.includes('not an email trigger')) {\n    // select an automation with an email trigger\n  }\n}","preventionTips":["Verify trigger.type before invoking email-specific test endpoints","Filter automation pickers to email-trigger automations for IMAP test flows","Re-check trigger type after any automation edit"],"tags":["automation","trigger","imap","type-mismatch"],"backgroundTag":"resource-type-mismatch","analyzedSha":"a81a902e9a8fe55b467d106765f6638f12e35c49","analyzedAt":"2026-08-29T01:03:10.972Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}