Brian
Brian3mo 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
Solution:
@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....
Jump to solution
17 Replies
AI Support
AI Support3mo 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 Chadha3mo 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
BrianOP3mo 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 Chadha3mo ago
you can share as well, when you submit via support it shares the current version (irrespective of the deployment)
Brian
BrianOP3mo 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 Chadha3mo 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
BrianOP2mo ago
@Gaurav Chadha Are there any news on this?
Gaurav Chadha
Gaurav Chadha2mo ago
Hey @Brian, it's in progress, we'll provide an update on fix this week. Thank you for your patience.
Solution
Gaurav Chadha
Gaurav Chadha2mo ago
@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.
Brian
BrianOP2mo ago
@Gaurav Chadha This seems not to work. I get an "Unexpected end of JSON Input" error on the first node you inserted the condition. Is this ID there a node id? Because my whole workflow has no such ID, so I wonder where this is coming from
No description
Gaurav Chadha
Gaurav Chadha2mo ago
It is the Id from the looped items not, if you check the logs, it matches the undefined condition correctly. you can check the logs on which input this error is coming on the execute workflow node.
Brian
BrianOP2mo ago
@Gaurav Chadha Ah yeah, so the remote workflow had some issues. I fixed that, but I am still curious where this id for the "loop items" is coming from. Is this some sort of a global internal id?
Gaurav Chadha
Gaurav Chadha2mo ago
Cool, the Id is of the items that were getting mapped within the loop, we copied your default variable in the condition and removed the item ID and mapped it with the required onne and used optional chaining. It isn't any internal ID. We'll be pushing a default fix soon, as mentioned in the email.
Brian
BrianOP2mo ago
Has this been fixed yet or are you currently working on a fix? For some reason it does not work anymore and I noticed that the loop items are now sometimes being mapped, for example: ctx["root"]["277483-27472-3847"].map(_=>_["2848-284828-28482"]) The ID you mentioned before is the id of the node within the loop, right?
Gaurav Chadha
Gaurav Chadha2mo ago
the fix will be released along with the new version. Yeah, the id is for one of the loop item
Brian
BrianOP2mo ago
I sent you another app support request. My ID seems to not work and I don't understand what's wrong. I also can't see any workflow logs because they apparently never stop running. Can you please CC Stefan from my workspace when you reply via E-Mail.
Gaurav Chadha
Gaurav Chadha2mo ago
Sure, @Brian, you have added correct ID, and it is working, the issue seems ad the last parallel node, where the execution is not getting completed and getting stuck, checking and will revert here and on email asap.