โ02-26-2021 05:26 AM
I believe I've uncovered a rather serious bug. Let's say I have a repeat action and if an error occurs during an iteration, I want to catch it, wait X seconds, then retry the whole repeat action again.
Simple Ruby program that demonstrates this:
Output: [0, 1, 2, 3, 4]
Here's the recipe version in Workato: https://app.workato.com/recipes/1443583?st=ff6418
This recipe outputs [2, 3, 4], which is not correct. What I would expect is for the entire loop to repeat from index 0 on every attempt. Note that the list and repeat helper list are created anew per each attempt. However, it appears as if the loop is continuing at a previously stored offset.
This has produced serious production bugs for us. Can someone explain if my assumptions here are incorrect or if I've built the recipe logic incorrectly?
โ02-26-2021 10:13 PM
Tridivesh Sarangi know anyone who could weigh in on this? ^
โ02-26-2021 10:52 PM
Try creating your list variable outside the outer loop and clearing it inside the loop before the first iteration in the inner loop each time. It might be creating multiple versions of the same list variable. When I updated and ran, it looks like it's ok to me.
https://app.workato.com/recipes/1444711?st=673352
โ02-27-2021 02:18 AM
Hi Amy, yes that works in this example! Thank you for sharing that. However, there may be cases where we may still need the list to be scoped within the context of the outer loop.
Regardless of the use case though, it seems that the way Workato manages local variable assignment within loops is very unintuitive and ways counter to how it works in most programming languages.
I basically restructured the recipes to avoid this construct, but it still leaves me wanting to know why this is considered expected behavior.