Fail the execution.
Used to fail the execution, for example, on a switch branch or on some conditions based on the execution context.
yaml
type: "io.kestra.plugin.core.execution.Fail"
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'] }}`"
}
Dynamic
YES
Optional condition, must coerce to a boolean.
Boolean coercion allows 0, -0, and '' to coerce to false, all other values to coerce to true.
Dynamic
YES
Default
Task failure
Optional error message.