Brian
Brian2w ago

Cannot access looped Node items if they were failing (undefined)

Imagine a workflow that has some nodes within a loop. These nodes could potentially fail, but that's okay, so I set an "On Fail" to "Ignore". Now after that loop I have another node that accesses one of the nodes within that loop. Due to the fact that this node is within a loop, I will get an array variable when referencing it. So far so good, but when I try to access that array's items with an index, it throws the error "Cannot read properties of undefined (reading '0')". I am not sure why, because even though if a node failed within the loop, it would still have an "undefined" at that index of the array. I attached my loop array as an image for reference. To be exact, consider this array as "array1" and "array2" is an array that has the exact same length, but without any undefined values. My goal is to retrieve all items from array2 that would match an "undefined " value from array1 like this: array2.filter((_, index) => array1[index] === undefined. My array clearly has at least an "undefined" at every index, so why am I getting this error?
No description
8 Replies
AI Support
AI Support2w ago
AI Support Bot Information
<@112676328783802368> you can react on the relevant answer (message) with a ✅ in this thread when you think it has been solved, by the bot or by a human! Anyone can react on this message with a ❌ if the GPT bot is unhelpful or hallucinating answers. Please note: Team members will review and answer the questions on best efforts basis.
Gaurav Chadha
Gaurav Chadha2w ago
Here, array2.filter((_, index) => array1[index] === undefined. you are checking if the item value of the array is undefined, but the whole result value is undefined. We'll check this and update you.
Brian
Brian2w ago
Okay, do you need a workflow example or do you understand the flow that I described completely? (I was also wondering what version would be sent if I write a Support ticket in the BuildShip app and add my workflow. Is it giving you a copy of that workflow in this very moment or do you also see the changes that I made afterwards?
Gaurav Chadha
Gaurav Chadha2w ago
you can share as well, when you submit via support it shares the current version (irrespective of the deployment)
Brian
Brian2w ago
Okay, I just shared a stripped down version via the Support button. Do you also see what I have set in the test body or would we normally have to give it to you too?
Gaurav Chadha
Gaurav Chadha2w ago
@Brian we are now tracking this as an issue, seems to be an issue with accessing undefined values, we'll update you on the fix.
Brian
Brian3d ago
@Gaurav Chadha Are there any news on this?
Gaurav Chadha
Gaurav Chadha23h ago
Hey @Brian, it's in progress, we'll provide an update on fix this week. Thank you for your patience. @Brian The issue was that the object properties were getting accessed on undefined values.For now, you can use the optional chaining whenever you encounter such a condition. We have modified the conditions a bit on the following nodes: 1. Branch Check for failed Prompts, 2. Retry Grounded-SAM, 3. Replace "Undefined" from Array. you can test your workflow again. Sent you can email with the fix and more details, you can followup on the email with more question.