New to Kestra?
Use blueprints to kickstart your first workflows.
Kestra blueprint demonstrating block level and flow level error handling, constant retries, errorLogs() debugging, and KV writes for downstream alerting.
Learn every layer of Kestra's failure handling model with one deliberately unreliable flow. A Python task raises an exception 99 percent of the time, which lets you watch, in order: the flow level retry policy re-running the failed task, the errors block inside the Sequential group firing with block scoped context, the flow level errors block firing with {{ errorLogs() }} output, and a KV store write that leaves behind context an external alerting flow can pick up. It is the reference companion to a namespace scoped alerting flow and a resubmission flow, together forming a complete detect, notify, retry pattern.
task_block group (io.kestra.plugin.core.flow.Sequential) contains log_message (io.kestra.plugin.core.log.Log) and fail_task (io.kestra.plugin.scripts.python.Script), which raises a RuntimeError when random.random() <= 0.99.retry policy (behavior: RETRY_FAILED_TASK, type: constant, maxAttempt: 2, interval: PT1S) retries only the failed task before the failure propagates.errors block attached to the Sequential group runs first: log_error_seq_block logs the failing {{ task.id }}, the {{ taskrun.id }} with its start date, and the collected {{ errorLogs() }}.errors block then runs: log_error_flow records the same debugging context at flow scope, and set_custom_vars (io.kestra.plugin.core.kv.Set) writes <flowId>-custom-label = marketing-report to the KV store so alerting flows can enrich their notifications.webhook_call trigger (io.kestra.plugin.core.trigger.Webhook) lets any external system, or a quick curl, start the flow on demand with a secret key.errors blocks with the exact template expressions for task, taskrun, and error logs.Most orchestrators give you a single on failure callback. Kestra layers the model: retries happen first and are policy, not code; errors blocks can be attached to any task group for local cleanup; a flow level errors block catches anything that escapes; and functions like errorLogs() expose the actual failure text to your handlers. Because the KV store persists context beyond the execution, downstream alerting and resubmission flows can react with full knowledge of what broke.
ERROR_HANDLING_WEBHOOK_KEY: shared secret guarding the Webhook trigger so only authorized callers can start failure drills.ERROR_HANDLING_WEBHOOK_KEY secret to your Kestra namespace.<flowId>-custom-label entry was written.type: exponential with a maxDuration for production realism.io.kestra.plugin.slack.notifications.SlackIncomingWebhook to the flow errors block for direct alerts.