EXIT Step
The EXIT step allows you to terminate the execution of a flow, loop, or sequence early based on a specific condition.
Properties
| Property | Type | Description |
|---|---|---|
type | string | Must be exit. |
from | string | The scope to exit from: flow, loop, or parent. |
signal | string | The exit status: SUCCESS or FAILURE (Default: FAILURE). |
condition | string | (Optional) Conditional expression (e.g., ${status} == 'DONE'). |
message | string | (Optional) Log message describing the reason for the exit. |
Exit Scopes (from)
1. from: "flow" (Default)
Terminates the entire Flow Service immediately.
- If
signal: SUCCESS, the flow ends normally. - If
signal: FAILURE, the flow ends with an error.
2. from: "loop"
Breaks out of the nearest enclosing LOOP or REPEAT step. Execution continues with the step immediately following the loop.
3. from: "parent"
Exits the immediate parent SEQUENCE or BRANCH case. Execution continues with the next step in the flow.
Examples
1. Simple Break in a Loop
yaml
- type: "loop"
in: "${data}"
item: "row"
steps:
- type: "exit"
from: "loop"
condition: "${row.id} == 0"
message: "End of data marker found, breaking loop"2. Early Success Return
yaml
- name: "ShortCircuit"
type: "exit"
from: "flow"
signal: "SUCCESS"
condition: "${cacheHit} == true"
message: "Serving from cache, skipping remaining steps"3. Custom Error Exit
yaml
- name: "ValidationError"
type: "exit"
from: "flow"
signal: "FAILURE"
condition: "${input.email} == ''"
message: "Invalid input: email is required"Data Flow Scenario: Early Success Return
Flow Definition:
yaml
steps:
- type: "exit"
from: "flow"
signal: "SUCCESS"
condition: "${type} == 'GUEST'"
message: "Exiting early for guest users"
- type: "invoke"
service: "auth:RegisterMember"Scenario 1: Type is 'GUEST'
- Initial Pipeline:
{ "type": "GUEST" } - Result: The flow stops immediately.
RegisterMemberis never called.
Scenario 2: Type is 'PRO'
- Initial Pipeline:
{ "type": "PRO" } - Result: The EXIT condition is not met. The flow continues to
RegisterMember.
Tips
- Debugging: The
messageproperty is invaluable for debugging non-linear flows. It will appear in the execution logs. - Combined with Branch: Often used inside a
BRANCHstep to handle validation failures or "short-circuit" logic. - SUCCESS signal: Using
signal: SUCCESSwithfrom: flowis a clean way to handle early returns without wrapping the rest of the flow in a giantifblock.
