Loop RESTQuery block fails, but want workflow to still complete

I have a workflow which takes an array, then a loop RESTQuery block runs each ID in the array through an API endpoint interpolating the ID into the url, then a code block to combine/mutate the results.

Trouble is some ID's will respond 404 from the query rest API, and I have no control over this part.

When I run the API query loop block independently it has a green checkmark and shows as successful, where the resulting array is just null for the failed results; this is great. I can then run the mutate code block + add to database.

But when I run the workflow as a whole, if one of the API calls fails it just stops the whole workflow and I can't figure out a way to go past that.

I would really like the workflow to still complete just with null results.

I've tried looking into the Error handlers but that didn't work, it logs the error but still fails overall. I tried putting if statement in the code version of the rest API query block but still fails.

Any ideas?


Hey @Kevin_O!

The dev team is looking at how errors in loop blocks can potentially be handled and I can let you know here when there's an update there!

In the meantime, we might be able to work around this by modifying some of how the Promise API is used in the loop code. If the starting point is this:

You might try adding catch to the query lambda trigger:

const results = [];
for (const [index, value] of code3.data.entries()) {
  const result = query8_lambda.trigger().catch(error => error);
return await Promise.all(results);

That, or you can try using allSetlled:

const results = [];
for (const [index, value] of code3.data.entries()) {
  const result = query8_lambda.trigger();
return await Promise.allSettled(results);

Does that work for you and allow you to build in some additional error handling?

Hey @Kabirdas , yeah on quick try looks like that worked! :tada: Thanks!