Budibase/budibase · error · Error

Failed to enable CRON or Email trigger for automation "${aut

Error message

Failed to enable CRON or Email trigger for automation "${automation.name}": ${err.message}

What it means

During publish, initDeployedApp re-enables CRON and email triggers for each production automation. If enabling any trigger rejects, the rejection is re-thrown as a new Error wrapping the cause with this message naming the automation. It aggregates quartz/queue-level failures into the deployment flow.

Source

Thrown at packages/server/src/api/controllers/deploy/index.ts:119

    await db.allDocs<Automation>(
      getAutomationParams(null, {
        include_docs: true,
      })
    )
  ).rows.map(row => row.doc!)
  await clearMetadata()
  let { count } = await disableAllCrons(prodAppId)
  const promises = []

  for (let automation of automations) {
    promises.push(
      enableCronOrEmailTrigger(prodAppId, automation)
        .then(({ enabled, automation, clearedRepeatableJobs }) => {
          count += clearedRepeatableJobs
          return { enabled, automation }
        })
        .catch(err => {
          throw new Error(
            `Failed to enable CRON or Email trigger for automation "${automation.name}": ${err.message}`,
            { cause: err }
          )
        })
    )
  }
  const results = await Promise.all(promises)
  const enabledCount = results
    .map(result => result.enabled)
    .filter(result => result).length
  console.log(
    `Cleared ${count} old CRON/email, enabled ${enabledCount} new CRON/email triggers for app deployment`
  )

  const knowledgeSourceSyncSummary = await context.doInWorkspaceContext(
    prodAppId,
    async () => {
      const agents = await sdk.ai.agents.fetch()

View on GitHub (pinned to a81a902e9a)

Solutions

  1. Read the cause (err.cause) to find the underlying Quartz/Redis failure
  2. Open the named automation in the builder and validate/fix its CRON expression or email trigger config
  3. Check Redis connectivity and health for the worker during publish
  4. Delete and re-save the offending automation trigger to rebuild its schedule
  5. Re-run the publish after fixing the automation

Example fix

// before
cron: "0 25 6 * * *"
// after ( Quartz requires 6-7 fields; verify format )
cron: "0 0 6 * * ?"
Defensive patterns

Strategy: try-catch

Validate before calling

const cron = automation.definition?.trigger?.inputs?.cron
if (cron && !/^\S+\s+\S+\s+\S+\s+\S+\s+\S+(\s+\S+)?$/.test(cron.trim())) {
  throw new Error(`Automation ${automation.name} has invalid cron: ${cron}`)
}

Try / catch

try {
  await api.post(`/api/applications/${appId}/publish`)
} catch (err) {
  if (err.message.startsWith("Failed to enable CRON or Email trigger")) {
    console.error("Automation:", err.message, "cause:", err.cause)
    // fix the named automation's trigger, then re-publish
  } else { throw err }
}

Prevention

When it happens

Trigger: enableCronOrEmailTrigger fails for a specific automation during publishWorkspaceInternal — e.g. Quartz job registration throws, a Redis/BullMQ queue error occurs, the automation has a malformed CRON expression, or an email trigger config is invalid.

Common situations: Corrupted automation doc after import; CRON string that the scheduler rejects; Redis unavailable or flushed mid-publish; duplicate repeatable jobs from a previous failed publish.

Related errors


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