-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
Problem:
Right now, every step in a RestBook playbook runs unconditionally. For real-world use cases (like syncing users or skipping optional steps), we need a way to conditionally execute steps based on variable values or previous responses.
✅ What to Implement
- Add a new
when:
field toStepConfig
- Allow a Jinja2 expression to be evaluated at runtime
- If
when:
evaluates tofalse
, the step is skipped - Log skipped steps clearly (e.g., "Step 2 skipped (when=false)")
- Skipped steps should not store or mutate variables
🔧 Example Syntax
steps:
- name: check-user
request:
method: GET
endpoint: /users/{{ user_id }}
store:
- var: user_exists
jq: '.id != null'
- name: create-user
when: "{{ not user_exists }}"
request:
method: POST
endpoint: /users
data:
id: "{{ user_id }}"
email: "{{ user_email }}"
💡 Why It Matters
- Enables idempotent API workflows by skipping redundant operations
- Reduces unnecessary API calls and avoids unintended side effects
- Makes playbooks more dynamic, readable, and declarative
- Helps backend/data engineers build safer integrations with fewer steps
- Opens the door for richer control flow (like branching logic)
📎 Related Ideas
- Allow
when:
at the phase level to skip entire phases conditionally - Log skipped steps clearly in both output and summary logs
- Add support for
--show-skipped
in CLI to report skipped steps explicitly - Future: Add
else:
orotherwise:
clause to support step-level fallback - Combine with dry-run mode to preview which steps would run or skip
Metadata
Metadata
Assignees
Labels
No labels