
Core Plugins and tasks Fail
CertifiedIntentionally fail the execution.
Core Plugins and tasks Fail
Certified
Intentionally fail the execution.
Throws an error to end the flow. If condition is provided, it is rendered and coerced to boolean (via TruthUtils); failure occurs only when it is truthy. Without condition the task always fails.
Use errorMessage to control the logged/raised message; helpful for explicit branch failures or alert routing.
yaml
type: io.kestra.plugin.core.execution.FailExamples
Fail on a switch branch
yaml
id: fail_on_switch
namespace: company.team
inputs:
- id: param
type: STRING
required: true
tasks:
- id: switch
type: io.kestra.plugin.core.flow.Switch
value: "{{inputs.param}}"
cases:
case1:
- id: case1
type: io.kestra.plugin.core.log.Log
message: Case 1
case2:
- id: case2
type: io.kestra.plugin.core.log.Log
message: Case 2
notexist:
- id: fail
type: io.kestra.plugin.core.execution.Fail
default:
- id: default
type: io.kestra.plugin.core.log.Log
message: default
Fail on a condition
yaml
id: fail_on_condition
namespace: company.team
inputs:
- name: param
type: STRING
required: true
tasks:
- id: before
type: io.kestra.plugin.core.debug.Echo
format: I'm before the fail on condition
- id: fail
type: io.kestra.plugin.core.execution.Fail
condition: '{{ inputs.param == "fail" }}'
- id: after
type: io.kestra.plugin.core.debug.Echo
format: I'm after the fail on condition
Using errorLogs function to send error message to Slack
yaml
id: error_logs
namespace: company.team
tasks:
- id: fail
type: io.kestra.plugin.core.execution.Fail
errorMessage: Something went wrong, make sure to fix it asap!
errors:
- id: slack
type: io.kestra.plugin.notifications.slack.SlackIncomingWebhook
url: "{{ secret('SLACK_WEBHOOK') }}"
payload: |
{
"text": "Failure alert for flow `{{ flow.namespace }}.{{ flow.id }}` with ID `{{ execution.id }}`. Here is a bit more context about why the execution failed: `{{ errorLogs()[0]['message'] }}`"
}
Properties
condition string
Optional condition, must coerce to a boolean.
Boolean coercion allows 0, -0, and '' to coerce to false, all other values to coerce to true.
errorMessage string
Default
Task failureOptional error message
pluginDefaultsRef Non-dynamicstring
Reference (ref) of the pluginDefaults to apply to this task.