Preventing action loops
How to Prevent Action Loops in Mechanic Tasks
Manual Prevention
1. Conditional Checks
Example: Skip Tagging if Tag Already Exists
{% if event.topic == "shopify/products/update" or event.preview %}
{% assign existing_tags = product.tags | split: ", " %}
{% unless existing_tags contains "NewTag" %}
{% action "shopify" %}
mutation {
tagsAdd(
id: {{ product.admin_graphql_api_id | json }},
tags: ["NewTag"]
) {
userErrors {
field
message
}
}
}
{% endaction %}
{% else %}
{% log "break loop" %}
{% endunless %}
{% endif %}2. Timestamp-based Approach
Automated Prevention
Mechanic's Built-in Features
Conclusion
Last updated
Was this helpful?