Docs / Strand / advanced/error-handling
Error Handling
Learn how to handle errors in Strand workflows.
Overview
Errors can occur at various points in workflow execution. Strand provides several mechanisms for handling them gracefully.
Error Types
Node Execution Errors
When a node fails to execute:
- HTTP request fails
- Template rendering error
- Invalid configuration
- External service unavailable
Workflow Errors
- Infinite loop detection
- Invalid workflow structure
- Missing required fields
Error Handling Strategies
Default Values
Use the default filter to handle missing data:
{{ payload.email | default('[email protected]') }}
Conditional Checks
Check for data existence before using:
{% if steps.user_lookup.output_payload %}
{{ steps.user_lookup.output_payload.email }}
{% else %}
{{ 'No user found' }}
{% endif %}
Error Information
When a node fails, error information is available:
- Error message - Description of the error
- Error type - Category of error
- Node ID - Which node failed
- Timestamp - When the error occurred
Best Practices
- ✅ Always handle HTTP request errors
- ✅ Use if/else branching to check for error conditions
- ✅ Log errors with print nodes for debugging
- ✅ Provide fallback values with
default - ✅ Test error scenarios
- ✅ Monitor error rates in production
Common Error Scenarios
Missing Data
Problem: Referencing data that doesn't exist
Templates render in strict mode: referencing a missing variable or key raises an error rather than producing an empty string. Depending on where the template runs, this can fail the step (If/Else conditions and sub-workflow inputs), set a field to null (Transform mappings), or pass the raw template text through (other node configs). Always guard optional fields.
Solution:
{{ payload.user.email | default('[email protected]') }}
See Jinja2 Error Handling for the full per-context behavior table.
Template Errors
Problem: Invalid Jinja2 syntax
Solution:
- Check syntax carefully
- Test templates incrementally
- Use execution logs to debug
Network Errors
Problem: External API unavailable
Solution:
- Use if/else branching to handle failure cases
- Configure retry logic on HTTP request nodes
- Provide fallback behavior
Related
- Conditional Logic - Using if/else branching
- Jinja2 Syntax - Safe data access
Tendrl