cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

Nested repeat action retried within an error block using incorrect indices

jason1
Deputy Chef I
Deputy Chef I

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?





7 REPLIES 7

kristine
Workato employee
Workato employee

Tridivesh Sarangi know anyone who could weigh in on this? ^

ajorde
Deputy Chef I
Deputy Chef I

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

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.